mysql> desc A;
+----------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+-----+---------+----------------+
| id | int(10) | NO | PRI | NULL | auto_increment |
| uid | int(10) | NO | | NULL | |
| uname | varchar(30) | NO | | NULL | |
| pwd | varchar(20) | NO | | NULL | | |+----------------+-------------+------+-----+---------+---------------+
mysql> desc B;
+----------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+-----+---------+----------------+
| id | int(10) | NO | PRI | NULL | auto_increment |
| uname | varchar(30) | NO | | NULL | |
|+----------------+-------------+------+-----+---------+---------------+
如果要提取表A.uname中不存在于表B.uname的值,其MySQL语句如下:
SELECT *
FROM A
LEFT JOIN B ON A.uname=B.uname
WHERE B.uname IS NULL
阅读(1475) | 评论(0) | 转发(0) |