0

i am adding multiple category id in field like , 127-157-526-5222-

now i am trying to fetch data but getting nothing. can anyone help me in this problem, getting 0 result.

my query is

SELECT * FROM tblprods WHERE FIND_IN_SET('157', tblprods.categories)
Strawberry
  • 33,750
  • 13
  • 40
  • 57

1 Answers1

0

Since FIND_IN_SET works for comma separated values (CSV) try replacing the hyphens with comma first.

SELECT * FROM tblprods WHERE FIND_IN_SET('157', REPLACE(tblprods.categories,'-',','));

Caution:

Is storing a delimited list in a database column really that bad?

YES

Community
  • 1
  • 1
1000111
  • 13,169
  • 2
  • 28
  • 37