-   Programming (
-   -   SQL: multiple WHERE statements (

elvijs 07-02-2007 09:07 AM

SQL: multiple WHERE statements
Is something like this possible in a "clean" way?

SELECT * FROM table WHERE id = '1' OR id = '11' OR id = '9' OR id = '4' OR id = '6'
and so on...

For example I want to select information only about particular records (using PHP). I have an array with the records' ids (the size of array is unknown). Can I do something like this or is it impossible?

SELECT * FROM table WHERE id = '$array';

Guttorm 07-02-2007 09:09 AM


Try this:
PHP Code:

$ids join(",",$array);
$sql "SELECT * FROM table WHERE id IN ($ids)"

elvijs 07-02-2007 09:17 AM

Really thanks, it works.

All times are GMT -5. The time now is 08:05 PM.