Home ›
MySQL WHERE ... IN (1, 4, 5) syntaxMySQL WHERE ... IN (1, 4, 5) syntax
Submitted by Benjamin Melançon on October 14, 2007 - 9:12am
For maximum ease of use, the answer is in the title.
From DevArticles Forum:
SELECT foo FROM bar WHERE foo IN (1,2)
Allegedly:
Note that the IN is an array. If you have a large amount of items it may be easier to use
IN $array
rather than write a long query.
Resolution
Searched words:
mysql IN command
mysql IN statement
SELECT WHERE IN
mysql WHERE IN
IN function
Comments
WHERE IN $array
What is the syntax for this as this - WHERE IN $array - does not work.
Thanks
the appropiate syntax is $sql
the appropiate syntax is
$sql = "
...
WHERE
[FIELD] IN ( ".implode( ',' , $array_of_numbers )."
";
Saludos
$array is php syntax
$array is php syntax
Post new comment