sql - How to get a list from comma seperated data in mysql -


i want use sql this:

select * product   productid in (select relatedproductids                         product                        productid = 11) 

relatedproductids contains '2286,11212,11031,11212,11212,4082,9339,9214'

do have suggestion?

use find_in_set()

select  a.*    product         inner join product b             on find_in_set(a.productid, b.relatedproductids) > 0   b.productid = 11         

as advice, should normalize table. saving comma separated value in column bad design.


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -