sunny sunny - 4 months ago 8
MySQL Question

How to match Value from string in Mysql PHP

I have a table

methodology
in mysql where a column contain values like
1,2,3,4,5,6
or
3,4,6
or
25,4,7,8
in multiple row.

Now in my scenario i have a company which contain id
6
and i want to Match this value with methodology table value. But i don't have any idea how i can do it.

I am trying that first it get all values from methodology table one by one and after that match value of company.

can anyone please help me??

Answer

You can use FIND_IN_SET(your_id, columnname) function.

Query will be like

SELECT * FROM
methodology 
where FIND_IN_SET(your_id, columnname)

For more details about function please refer : http://www.w3resource.com/mysql/string-functions/mysql-find_in_set-function.php