searching csv values from a single feild in mysql

I have a 'new_view' table as below:
device-----adapter-----prod_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
LVL 8
shaunakAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

theGhost_k8Database ConsultantCommented:
Try:
where FIND_IN_SET('4',fieldname)>0
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hieloCommented:
try:
SELECT *  FROM `new_view` WHERE CONCAT(',', `prod_ids`,',') LIKE '%4%'
0
shaunakAuthor Commented:
For hielo suggestions it also returns prodid with 14


Trying combination with theGhost_k8 suggestion
0
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

shaunakAuthor Commented:
For hielo suggestions it also returns prodid with 14


Trying combination with theGhost_k8 suggestion
0
shaunakAuthor Commented:
For hielo suggestions it also returns prodid with 14


Trying combination with theGhost_k8 suggestion
0
shaunakAuthor Commented:
Thanks hielo
Your suggestion worked for all possibilities.
Thanks to theGhost_k8 for your comments.


0
shaunakAuthor Commented:
Thanks hielo
Your suggestion worked for all possibilities.
Thanks to theGhost_k8 for your comments.


0
shaunakAuthor Commented:
Thanks for the pin point solution
0
shaunakAuthor Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.