简体   繁体   中英

how to match one id with multiple comma separated ids

I have a table demo

ID        collectionID

1           1,3,4
2           3,5
3           30,35,2 
4           4,5
5           2,3,30

Now, I want to getting rows which collectionID=3 using MYSQL query.

desired output will be -

1           1,3,4
2           3,5
5           2,3,30

Use FIND_IN_SET() , like this:

SELECT *
FORM myTable
WHERE FIND_IN_SET('3', collectionID)

尝试这个

select * from tbl_name where FIND_IN_SET("3",collectionID);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM