0

I'm trying to search a value in a mysql table field. using prepared statements.

services: 2,4,5

passed value: 2

$query = "SELECT *
          FROM table
          WHERE services IN(':array')"

so basically I'm trying to return all rows where 2 is inside the services field. The field itself will have numbers separated by commas. So the services field can look like this: 2,3,6,7,1 or just something like this: 4. Any help is greatly appreciated.

user939951
  • 77
  • 5
  • 9
    see http://stackoverflow.com/q/14767530/ and http://stackoverflow.com/q/1586587/ and http://stackoverflow.com/q/920353/ should get you in the right direction. – Funk Forty Niner Dec 24 '15 at 21:10

1 Answers1

0
$query = "SELECT *
          FROM table
          WHERE FIND_IN_SET(':array', services )"

:array is 2 what u want pass.

Szymon
  • 106
  • 4