Hi, I have some problem with mysql query,.. i have a field in my mysql which called with: software: varchar(250) this field is information about software that member capable in. It can be inserted by more than one value which is seperated by comma. the Values is number from 1 until 25. this data bellow is for example: id --- software 1 --- 2,3,13 2 --- 6,12,14,15 3 --- 3,4,7,9,13,23,24 4 --- 1,13 5 --- 2 6 --- 10,11 my question: what is the query substring script to find a value in a data that containing value (x), for example i want to know which rows that containing value 13. Thank you very much
Use regular expressions: SELECT * FROM `software` WHERE REGEXP '(,)?$x(,)?' Code (markup): Never used REGEXP before, so if the above does't work, read the manual: http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator_regexp Peace,
This won't work if x is only in the table, should be: SELECT * FROM `tableName` WHERE `software` LIKE '$x,%' OR `software` LIKE '%,$x,%' OR `software` LIKE '%,$x' OR `software` = '$x' PHP: Also you need the field software to be a "fullindex". Peace,