I have to select all rows from table where column_x contains specific value. Although those values are separated with comas and I need to split them at first and check if the first value after splitting contains the string which I'm looking for.
Asked
Active
Viewed 19 times
0
-
Either use FIND_IN_SET() or (the best way) normalize your data. – Akina Jun 17 '21 at 12:53
-
1Fix your data model! Don't store multiple values in a string! – Gordon Linoff Jun 17 '21 at 12:56
-
1Ok, guys, I found the solution: SELECT * FROM `mytable` WHERE SUBSTRING_INDEX(`mycolumn`, ",", 1) LIKE '%myvalue%' – Michał Sikora Jun 17 '21 at 12:58