Khalid Usman Khalid Usman - 23 days ago 8
SQL Question

Inner query comma separated results

My Query is:

SELECT project_type_name FROM project_type WHERE project_type_id IN
(SELECT project_type_id FROM projects WHERE project_id = 93)


Where inner query returns 1 row with 3 comma separated values. (2,3,4). But outer query returns only 1 record only for 2.

Answer

You should use find_in_set for this purpose.

SELECT project_type_name FROM project_type WHERE FIND_IN_SET( project_type_id, (

SELECT project_type_id FROM projects WHERE project_id =93 ) )