Check if a value is present in one of the database rows

I need a way to check if a value is present in one of the rows of a page column.

For example, if you want to check if the value "45" is present?

 Id | page     |
 ---------------
 1  | 23       |
 ---------------
 2  |          |
 ---------------
 3  | 33,45,55 |
 ---------------
 4  | 45       |
 ---------------
+4
source share
2 answers

Function find_in_setis what you are looking for:

SELECT *
FROM   mytable
WHERE  FIND_IN_SET('45', page) > 0
+2
source

You cannot save values ​​in lists. This is especially true in this case:

  • Values ​​must be stored in the appropriate data type. You save numbers as characters.
  • External relations must be correctly defined.
  • SQL does not have very good string handling functions.
  • Result queries cannot use indexes.
  • SQL , . .

, . find_in_set(), Mureinik.

+1

All Articles