How to use a value in WHERE clause from a comma separated string in a MySQL Table?

Problem :

How to get records from a table that contains 24 as DeptID. I've added the table structure. What is the SQL query to get the ID and NAME that contains 24 as DeptID?

ID  NAME    DeptID
--- -----   -------
1   balaji  1,136,12,53,48,2,153,45,78,53,10,3,143,53,46,49
2   scott   24,90,120
3   balraj  43,9,24,901

Solution :

We can use find_in_set function in MySQL.



select * from Users where FIND_IN_SET('$deptid', DeptID);

Mysql Tutorials

Mysql Howto..

Show/disable button with PHP and JavaScript

How to write LEFT OUTER JOIN on the same table in jOOQ?

How to select only the first line from an raw in mysql

How to prevent multiples instances of a script?

mysql - how to display count of a value in an extra column

How to fetch values with a MySQL query?

How to configure the structure of a mysql database

How to omit select results based on IDs from another table in mySQL?

How to pull data from sub-array, and combine

Using spring to connect to mysql, how to mimick connection pool?

Only one result out of ten showing in table

how to mysql group by date multiple left join

How to speed up MySQL INSERTs/UPDATEs?

knowning how many rows are left with mysql_fetch_*

How can I turn data from MySQL to a jQuery variable?

How to display image depending of result in MySQL query, using PHP

How to generate array from multiple mysql rows with a common value

Reload div using jquery load function working only once and how to pass a variable

How do I run MySQL commands?

How to connect to mysql database using java?

MYSQL How to show most popular items in the last two days

How connect to mysql with python via odbc

How to transform a normalised data set using PHP?

How to insert records from a mysql query to a wxPython listCtrl widget?

How to create trigger in mysql?

How to get multiple rows of JSON data and put it into some sort of Array?

MySQL How to print the result of this query? [closed]

How to store 00 instead of 0 as DEFAULT to integer field in mysql?

How to filter the rows by points. PHP/MySQL

How to install Mysql 5.0.29 in Windows 7