Manish Jangir
Manish Jangir

Reputation: 5437

Multiple AND conditions in a mysql query

+------------+--------------------+----------+-------------+
| id_product | name               | id_brand | id_category |
+------------+--------------------+----------+-------------+
|          1 | Nokia E55          |      120 |           1 |
|          2 | Nokia E75 (Red)    |      101 |           1 |
|          3 | Nokia N86          |      105 |           2 |
|          4 | Nokia 6700 Classic |      110 |           2 |
|          5 | Nokia 6260 Slide   |      120 |           1 |
+------------+--------------------+----------+-------------+

What I want to do is, I have the following data

id_category = 1,2
id_brand = 110,105

Now I want the following products

Nokia 6700 Classic
Nokia N86

only

because there is no brand (110,105) in id_category 1.......

Upvotes: 0

Views: 50

Answers (3)

Madhivanan
Madhivanan

Reputation: 13700

Try this:

WHERE id_category in (1,2) and  id_brand in (110,105)

Upvotes: 1

Sadikhasan
Sadikhasan

Reputation: 18600

Try this

select name from tbl_name where id_category in (1,2) and id_brand in (110,105);

Upvotes: 1

Aziz Shaikh
Aziz Shaikh

Reputation: 16524

I believe you are looking for this:

WHERE id_category IN (1,2) AND id_brand IN (110,105)

Upvotes: 1

Related Questions