Answer the question
In order to leave comments, you need to log in
How to get an element in the list which does not have the desired value?
There is a table with data:
id | value | list
The list
data of the form is stored in 111 222 333 444
(I haven’t figured out how best to store them, the data list
will constantly increase, up to thousands in one line, it seems to me that this is not quite the right way ...)
The data in the table:
id | value | list
-------------------------
1 | ... | 111 222 333
2 | ... | 333 444
3 | ... | 555 444 333
4 | ... | 444 111 333
5 | ... | 111 222
id
(i.e. id == 2
) where in list
no 111
? SELECT * FROM table WHERE list NOT LIKE '%111%' OR NOT NULL ORDER BY id LIMIT 1
Answer the question
In order to leave comments, you need to log in
SELECT * FROM table
WHERE CONCAT(' ', list, ' ') NOT LIKE '% 111 %'
ORDER BY id LIMIT 1
You need to separate list into a separate table.
And set the conditions in the sample as aggregation functions (google SQL HAVING)
infoblocks showed users
id | value info_id | user_id id | name
----------- ------- | -------- --- | --------
1 | ... 111 | 333 111 | 333
2 | ... 333 | 222 333 |
3 | ... 555 | 333 555 | 333
4 | ... 444 | 333 444 | 333
5 | ... 111 | 555 111 |
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question