有时,我们需要对比两张表的数据,找到在其中一张表,不在另一张表中的数据
hql 如下:
SELECT *
FROM
(SELECT id
FROM a
WHERE dt = '2019-03-17' ) a
LEFT JOIN
(SELECT id
FROM b
) b ON a.id = b.id
WHERE b.id IS NULL;
2024-01-05 15:52:40
有时,我们需要对比两张表的数据,找到在其中一张表,不在另一张表中的数据
hql 如下:
SELECT *
FROM
(SELECT id
FROM a
WHERE dt = '2019-03-17' ) a
LEFT JOIN
(SELECT id
FROM b
) b ON a.id = b.id
WHERE b.id IS NULL;