使用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%''