LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   SQL: multiple WHERE statements (https://www.linuxquestions.org/questions/programming-9/sql-multiple-where-statements-566039/)

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

Hi

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 06:56 PM.