mysql> select table1.* from table1 LEFT JOIN table2 ON table1.id=table2.id where table2.id is NULL;这个例子找出在table1中所有的行,其id值在table2中不存在(即,所有table1中的在table2中没有对应行的行)。当然这假定table2.id被声明为NOT NULL。
mysql> select id from tt3 where not exists (select id from tt2 where tt2.id=tt3. id);
LEFT JOIN table2 ON table1.id=table2.id
where table2.id is NULL;这个例子找出在table1中所有的行,其id值在table2中不存在(即,所有table1中的在table2中没有对应行的行)。当然这假定table2.id被声明为NOT NULL。
id);