MySQL中计算差集可以使用NOT IN或LEFT JOIN语句。

  1. 使用NOT IN语句:

SELECT * FROM table1 WHERE column1 NOT IN (SELECT column2 FROM table2);

这将从table1中选择column1不在table2中column2的所有行。

  1. 使用LEFT JOIN语句:

SELECT table1.* FROM table1 LEFT JOIN table2 ON table1.column1 = table2.column2 WHERE table2.column2 IS NULL;

这将从table1中选择不与table2中的任何行匹配的所有行。

mysql计算差集

原文地址: https://www.cveoy.top/t/topic/fnKT 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录