2

Suppose I have table name called group and in which because of some reason I've comma separated values in field X now I want to compare an array with that field in mysql if array matches exact same then result should return.

For example : I've a row

1 - a,b,c 2 - x,y,z

so if array contains :

array(b,a,c) // Return row 1 
array(z,x,y) // Return row 2 
array(a,b) // Return false
Panther
  • 3,312
  • 9
  • 27
  • 50
Mohit Bumb
  • 2,466
  • 5
  • 33
  • 52

1 Answers1

-2

You might use the FIND_IN_SET function. Something like the following would work for your case on requiring b,a,c:

select * from table where FIND_IN_SET("b", `column`) AND FIND_IN_SET("c", `column`) AND FIND_IN_SET("c", `column`);

Please see the fiddle

Luceos
  • 6,629
  • 1
  • 35
  • 65