当前位置: 代码迷 >> PB >> 求各位写一SQL语句-mysql
  详细解决方案

求各位写一SQL语句-mysql

热度:40   发布时间:2016-04-29 09:49:56.0
求各位大虾写一SQL语句---mysql
tableName: products

products_id language_id text
-------------------------------------------
1 1 xxx
1 2 bbbc
1 3 aa
2 1 xx
3 1 bb
3 3 bbbbs
4 1 zxc
5 1 zxcd
6 1 sda
7 2 xxx
.....................
-------------------------------------------------

要求能够实现:
-->查出 language_id 中不包含2的所有其他产品信息
或者查出 language_id 中不包含3的所有其他产品信息。。。或者不包含1的...


------解决方案--------------------
SQL code
select * from product a where not exists(select 1 from product b where b.product_id = a.product_id and b.language_id = 1)
------解决方案--------------------
探讨
SQL code
select * from product a where not exists(select 1 from product b where b.product_id = a.product_id and b.language_id = 1)
  相关解决方案