亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 2284 | 回復(fù): 3
打印 上一主題 下一主題

mysql嵌套查詢問題 [復(fù)制鏈接]

論壇徽章:
1
白羊座
日期:2014-11-19 14:18:59
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2009-11-23 17:31 |只看該作者 |倒序?yàn)g覽
mysql> select * from a where domain not in (select domain from b);

ERROR 1064: You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'select domain from b)' at line 1


這個查詢哪里錯了呀?

如果改成多表聯(lián)合查詢怎么改。

[ 本帖最后由 鴻鈞 于 2009-11-23 17:37 編輯 ]

論壇徽章:
1
白羊座
日期:2014-11-19 14:18:59
2 [報(bào)告]
發(fā)表于 2009-11-23 17:35 |只看該作者
難道是我mysql版本的問題。

[root@localhost ~]# mysql -V
mysql  Ver 12.22 Distrib 4.0.27, for pc-linux-gnu (i686)

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2009-11-23 17:53 |只看該作者
Try:
select * from a where domain not exists (select 1 from b where domian=a.domain);

論壇徽章:
9
每日論壇發(fā)貼之星
日期:2016-01-04 06:20:00數(shù)據(jù)庫技術(shù)版塊每日發(fā)帖之星
日期:2016-01-04 06:20:00每日論壇發(fā)貼之星
日期:2016-01-04 06:20:00數(shù)據(jù)庫技術(shù)版塊每日發(fā)帖之星
日期:2016-01-04 06:20:00IT運(yùn)維版塊每日發(fā)帖之星
日期:2016-01-04 06:20:00IT運(yùn)維版塊每日發(fā)帖之星
日期:2016-01-04 06:20:00綜合交流區(qū)版塊每日發(fā)帖之星
日期:2016-01-04 06:20:00綜合交流區(qū)版塊每日發(fā)帖之星
日期:2016-01-04 06:20:00數(shù)據(jù)庫技術(shù)版塊每周發(fā)帖之星
日期:2016-03-07 16:30:25
4 [報(bào)告]
發(fā)表于 2009-11-23 22:07 |只看該作者
5.0.22沒問題,也許是4.0還沒支持 not in嵌套子查詢吧吧

mysql> create table a (domain int);
Query OK, 0 rows affected (0.01 sec)

mysql> create table b (domain int);
Query OK, 0 rows affected (0.01 sec)

mysql> insert into a values(1),(2);
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> insert into b values(1);
Query OK, 1 row affected (0.00 sec)

mysql> select * from a where domain not in (select domain from b);
+--------+
| domain |
+--------+
|      2 |
+--------+
1 row in set (0.00 sec)


表連接查詢的話:
select a.* from a left join b on a.domain=b.domain where b.primary_key is null;
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP