Reputation: 2207
Im looking for a way to check if a value is present in one of the rows of the page column.
For example if should check if the value '45' is present?
Id | page |
---------------
1 | 23 |
---------------
2 | |
---------------
3 | 33,45,55 |
---------------
4 | 45 |
---------------
Upvotes: 4
Views: 168
Reputation: 1269773
You should not store values in lists. This is especially true in this case:
Sometimes, you are stuck with other people's really bad design decisions. In that case, you can use find_in_set()
as suggested by Mureinik.
Upvotes: 1
Reputation: 311308
The find_in_set
function is just what you're looking for:
SELECT *
FROM mytable
WHERE FIND_IN_SET('45', page) > 0
Upvotes: 2