0

hey there I don't know if this mentioned earlier but I want to do this sql statment

$sql1 = "SELECT product FROM products WHERE cat = 2";
$sql2 = "SELECT product FROM products WHERE cat = 3";
$sql3 = "SELECT product FROM products WHERE cat = 4";

I want these three $sql combined into one so its give me the products from 3 catgeories.
is good to use CONCAT of INNER JOIN ?

2
Contributors
1
Reply
11
Views
4 Years
Discussion Span
Last Post by diafol
1
$sql1 = "SELECT product FROM products WHERE cat IN (2,3,4)";

or

$sql1 = "SELECT product FROM products WHERE cat = 2 OR cat = 3 OR cat = 4";

or

$sql1 = "SELECT product FROM products WHERE cat BETWEEN 2 AND 4";

or

$sql1 = "SELECT product FROM products WHERE cat >= 2 AND cat <= 4";

and a few other ways...

Edited by diafol

Votes + Comments
thanks that was really helpful
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.