现在的位置: 首页 > 综合 > 正文

[转]mysql里not in语句怎么写

2013年09月11日 ⁄ 综合 ⁄ 共 693字 ⁄ 字号 评论关闭

使用mysql中经常会遇到的问题,记录下来

 

转自: http://database.e800.com.cn/articles/2007/630/1183147360019880660_1.html

 

 

 

select bid from board where not in (select bid from favorite)
但在
mysql里就提示SQL语句的语法不对,“...near ''select bid from favorite)''

--------------------------------------------------------------------------------

在MySQL中下列语句还不能工作:
SELECT * FROM table1 WHERE id IN (SELECT id
FROM table2);
SELECT * FROM table1 WHERE id NOT IN (SELECT id FROM
table2);
然而,在很多情况下,你可以重写查询,而不用子选择:
SELECT table1.* FROM
table1,table2 WHERE table1.id=table2.id;
SELECT table1.* FROM table1
LEFT JOIN table2 ON table1.id=table2.id where table2.id IS NULL
select a.user_name from tmp_user_user a left outer join briousr2 b
on a.user_name=b.user_name where b.user_name is null and a.user_name not
like ''%0%''

抱歉!评论已关闭.