且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Mysql:从表中选择不在另一个表中的行

更新时间:2022-12-10 17:30:20

如果您在另一条注释中提到有300列,并且想要在所有列上进行比较(假设这些列的名称相同),则可以使用NATURAL LEFT JOIN隐式联接两个表之间所有匹配的列名,这样您就不必手动输入所有联接条件了:

If you have 300 columns as you mentioned in another comment, and you want to compare on all columns (assuming the columns are all the same name), you can use a NATURAL LEFT JOIN to implicitly join on all matching column names between the two tables so that you don't have to tediously type out all join conditions manually:

SELECT            a.*
FROM              tbl_1 a
NATURAL LEFT JOIN tbl_2 b
WHERE             b.FirstName IS NULL