Click here to Skip to main content
15,886,088 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have table supportContacts where sizeid has id's seprated by comma

now i want to fetch all records where size id has 1 in it ??

below is link
:

http://sqlfiddle.com/#!2/30bd2/1[^]

it works fine when i search for one id

now i want to select all column have size id 1 or 2

http://sqlfiddle.com/#!2/30bd2/2[^]

for that i have written query

SQL
select id, sizeid from supportContacts
WHERE FIND_IN_SET('1,2',sizeid)

which does not work ? any help
Posted
Updated 22-Mar-14 23:23pm
v4

1 solution

You should use the next query:
SQL
select id, sizeid from supportContacts
WHERE FIND_IN_SET('1',sizeid) OR FIND_IN_SET('2',sizeid)
 
Share this answer
 
Comments
garav kumar mishra 23-Mar-14 6:30am    
hey but i don not want to user OR if in case i have to search for large number of records like 1,2,3,4,56,7 etc then ??
CHill60 23-Mar-14 6:42am    
Are you able to change your database schema? Instead of having a column with multiple values in it (=poor design) have a table to hold the one-to-many related sizeids
garav kumar mishra 23-Mar-14 7:27am    
yeah i can change it but i will be more complicated as i have lot of things dependent upon that any way to get result from query ??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900