If I have two Entities Entity1 and Entity2 which are mapped on both sides (or at least Entity2 is mapped in Entity1) I can do
select e1 from Entity1 e1
left join e1.entity2 e2
where e2.id is null
Is there an equivalent for this if I do not have e1.entity2
but only Entity2.entity1
?
I'd personally change your tables round the other way. There is an option of using RIGHT JOIN
but I would fail any code if I saw a RIGHT JOIN
during a code review;
SELECT *
FROM Entity2 e2
LEFT JOIN Entity1 e1
ON e2.IdField = e1.IdField
WHERE e1.IdField IS NULL
Also, you appear to be missing your join criteria, it's best to declare these
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.