db query SELECT with two variables

Hi Community :slight_smile:

I would like to edit this code to include both order_status 2 and 21 but don’t know the correct insertion of both …

[php]$query = “SELECT * FROM orders WHERE orders_status = ‘2’ ORDER BY date_purchased DESC LIMIT $start, $display”;[/php]

Pre Thanks for your time!
-Ken

Hi, you can do any of the following:

[php]$query = “SELECT * FROM orders WHERE orders_status = ‘2’ OR orders_status = ‘21’ ORDER BY date_purchased DESC LIMIT $start, $display”;
[/php]

or

[php]$query = “SELECT * FROM orders WHERE orders_status in (‘2’,‘21’) ORDER BY date_purchased DESC LIMIT $start, $display”;
[/php]

Thank you so much PHPcoder!

I used the 2nd suggestion as it looked a tad cleaner… works like a champ!

Great response :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service