Problem description: structure: test has two fields, For example, col1 content is: 26,59,6
Select an id, such as 59, and then enter a number, such as: 2000 Example: If there are the following three records, search for records with id 59 and value less than 2000: 26,59,6 | 1502.5,1690,2276.77 The three records with id 59 are searched, and then the second search condition is determined to be (that is, the numbers at the corresponding id positions are compared): 1690<2000 drop table test; create table test ( col1 varchar(100), col2 varchar(100)); insert test select '26,59,6', '1502.5,1690,2276.77' union all select '59,33,6', '3502.1,1020,2276.77' union all select '22,8,59', '1332.6,2900,1520.77'; select col1,col2 from (select *,find_in_set('59',col1) as rn from test) k where substring_index(concat(',',substring_index(col2,',',rn)),',',-1) <'2000'; +---------+---------------------+ | col1 | col2 | +---------+---------------------+ | 26,59,6 | 1502.5,1690,2276.77 | | 22,8,59 | 1332.6,2900,1520.77 | +---------+---------------------+ |
<<: js uses cookies to remember user page operations
>>: How to bind Docker container to external IP and port
1. Background Recently, some friends encountered ...
Uninstall the installed version on Ubuntu: sudo a...
1. The use of or syntax in MySQL, and the points ...
The basic structure of HTML hypertext documents is...
Table of contents Preface 1. Preparation 2. Actua...
Table of contents Related dependency installation...
SQL method for calculating timestamp difference O...
NC's full name is Netcat (Network Knife), and...
1 CSS style without semicolon ";" 2 Tags...
1. Command Introduction The cal (calendar) comman...
Article Structure 1. Preparation 2. Install Java ...
A must-have for interviews, you will definitely u...
1. First enter the server's mysql to modify p...
introduction Most people who have used databases ...
Preface When the system space usage is too large ...