shaunak
asked on
searching csv values from a single feild in mysql
I have a 'new_view' table as below:
device-----adapter-----pro d_ids
HY97C51-----No-----1,2,3,4 ,5,6
HF97PP1-----No-----3,4,5,6
FF9LP221-----No-----5,6
the last coloumn has product ids saved in csv.
I want to get device for prod_ids = 4
I tried below queries:
SELECT * FROM `new_view` WHERE `prod_ids` LIKE '%4%'
Gives wrong output
SELECT * FROM `new_view` WHERE `prod_ids` LIKE '4%'
doesnt consider values in prodids as 1,2,3,4
SELECT * FROM `new_view` WHERE `prod_ids` LIKE '%4'
doesnt consider values in prodids as 4,5,6
FireShot-capture--082----localho.gif
device-----adapter-----pro
HY97C51-----No-----1,2,3,4
HF97PP1-----No-----3,4,5,6
FF9LP221-----No-----5,6
the last coloumn has product ids saved in csv.
I want to get device for prod_ids = 4
I tried below queries:
SELECT * FROM `new_view` WHERE `prod_ids` LIKE '%4%'
Gives wrong output
SELECT * FROM `new_view` WHERE `prod_ids` LIKE '4%'
doesnt consider values in prodids as 1,2,3,4
SELECT * FROM `new_view` WHERE `prod_ids` LIKE '%4'
doesnt consider values in prodids as 4,5,6
FireShot-capture--082----localho.gif
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
For hielo suggestions it also returns prodid with 14
Trying combination with theGhost_k8 suggestion
Trying combination with theGhost_k8 suggestion
ASKER
For hielo suggestions it also returns prodid with 14
Trying combination with theGhost_k8 suggestion
Trying combination with theGhost_k8 suggestion
ASKER
For hielo suggestions it also returns prodid with 14
Trying combination with theGhost_k8 suggestion
Trying combination with theGhost_k8 suggestion
ASKER
Thanks hielo
Your suggestion worked for all possibilities.
Thanks to theGhost_k8 for your comments.
Your suggestion worked for all possibilities.
Thanks to theGhost_k8 for your comments.
ASKER
Thanks hielo
Your suggestion worked for all possibilities.
Thanks to theGhost_k8 for your comments.
Your suggestion worked for all possibilities.
Thanks to theGhost_k8 for your comments.
ASKER
Thanks for the pin point solution
ASKER
Some mess up in comments I think.
theGhost_k8 suggestion of
SELECT *
FROM `new_view`
WHERE FIND_IN_SET( '4', prod_ids ) >0
LIMIT 0 , 30
worked for me
theGhost_k8 suggestion of
SELECT *
FROM `new_view`
WHERE FIND_IN_SET( '4', prod_ids ) >0
LIMIT 0 , 30
worked for me
SELECT * FROM `new_view` WHERE CONCAT(',', `prod_ids`,',') LIKE '%4%'