user759235 user759235 - 6 months ago 9
SQL Question

check if value is present in one of the database rows

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 |
---------------

Answer

The find_in_set function is just what you're looking for:

SELECT *
FROM   mytable
WHERE  FIND_IN_SET('45', page) > 0
Comments