3

I have an array that contains strings

e.g array('14183f6c-9bf5', '074306fb-6eaf')

I want to convert this into a format readable for an mysql query with an IN statement but I keep getting issues as its a string..

Essentially get this to be formatted as such in my sql query - I am using implode but to no avail.. any ideas

Guid IN ("14183f6c-9bf5", "074306fb-6eaf")

$Guids = array('14183f6c-9bf5', '074306fb-6eaf');
$csv = implode('",', $Guids);
Zabs
  • 13,252
  • 42
  • 158
  • 277

2 Answers2

6

try something like this

$whereIn = implode('","', $array); $sql = 'SELECT * FROM table WHERE col IN ("'.$whereIn.'")';

krzysiej
  • 873
  • 9
  • 22
2

try with this :

$whereIn = '("' . implode('","', $array) . '")';
Halayem Anis
  • 7,485
  • 2
  • 22
  • 42