mysql查询中的多个AND条件

时间:2014-03-21 07:30:20

标签: mysql sql

+------------+--------------------+----------+-------------+
| 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 |
+------------+--------------------+----------+-------------+

我想要做的是,我有以下数据

id_category = 1,2
id_brand = 110,105

现在我想要以下产品

Nokia 6700 Classic
Nokia N86

因为id_category 1中没有品牌(110,105).......

3 个答案:

答案 0 :(得分:1)

我相信你正在寻找这个:

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

答案 1 :(得分:1)

试试这个:

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

答案 2 :(得分:1)

试试这个

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