Mysql查看来自两个不同表的数据

Mysql查看来自两个不同表的数据,mysql,sql,Mysql,Sql,表A 表B |-------------| |mohonID |nama| --------------- |1111 |xxx | |2222 |yyy | -------------- 结果 |-------------| |mohonID |nama| --------------- |1111 |xxx | --------------- 这是我的示例表。如何查看表A中没有数据的表B中的数据。我想查看的示例表是TableResult。使用mysql语句。mysql不

表A

表B

|-------------|
|mohonID |nama|
---------------
|1111    |xxx |
|2222    |yyy |
--------------
结果

|-------------|
|mohonID |nama|
---------------
|1111    |xxx |
---------------

这是我的示例表。如何查看表A中没有数据的表B中的数据。我想查看的示例表是TableResult。使用mysql语句。

mysql不支持EXCEPT运算符,但您可以执行以下操作:

|-------------|
|mohonID |nama|
---------------
|2222    |yyy |
--------------

这里有一种方法

SELECT * FROM TableA WHERE mohonID NOT IN(SELECT mohonID FROM TableB)
还有一个

select tablea.*
from tablea a
left join tableb b
  on a.mohonID=b.mohonID and a.nama=b.nama
where b.mohonID is null
select tablea.*
from tablea a
where not exists(
  select * 
  from tableb b 
  where a.mohonID=b.mohonID and a.nama=b.nama)