select id from table b where id not in table a
解决方案 »
- JDBC连接MySQL报错Communications link failure due to underlying exception
- 100分 求 like 匹配度问题
- access denied for user ''@'localhost'(using password:NO)
- 关于10万数据联合查询优化问题,急!!
- MYsql中的循环语法
- MYSQL能不能实现这样的操作?
- 怎么写这样的SQL语句!在线等!
- 如何让密码正确区分大小写?
- mysql中,查找name字段中包含字符串str的所有记录,sql语句怎么写?
- 数据库优化 FIND_IN_SET 逻辑问题
- mysql字符集的更改问题
- 现在求一SQL语句,急切中……
绝对正确的.
select ID form table a where ID not in (select ID form table b)
绝对正确的.不能执行吧,在mysql里
select ID form table b where ID not in (select ID form table a)
你可以执行看.
+----+------+
| id | name |
+----+------+
| 1 | a |
| 2 | b |
+----+------+
2 rows in set (0.00 sec)mysql> select * from b;
+----+------+
| id | name |
+----+------+
| 1 | a |
| 2 | b |
| 3 | c |
+----+------+
3 rows in set (0.00 sec)mysql> select id from b where id not in (select id from a);
ERROR 1064: You have an error in your SQL syntax. Check the manual that corresp
onds to your MySQL server version for the right syntax to use near 'select id fr
om a)' at line 1
mysql>我的mysql的版本是4.0.20a-nt
select a.id, b.name from a, b where a.id=b.id
说明,从a,b表中分别取一个字段,条件是他们的id相等。
哎,没辙了。
select ID form table a where ID not in (select ID form table b)
2.否则的话好象不能用一个SQL解决问题。