且构网

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

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

更新时间:2022-12-10 17:26:22

如果您在另一条评论中提到有 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