I have a table that has amongst other things an ID column and a parent ID column:
id |parentID
------------
1 | 1
2 | 1
3 | 3
4 | 3
5 | 5
6 | 5
So basically there is an entry with id = parentID and some entry with an parentID which is an ID from some other row. Sometimes the entries with parentID <> id are missing, but id = parentID are always there. My goal is to find all those id = parentID entries that don't have the corresponding id <> parentID entry. How can it be done in Firebird 1.5? Thank you!
You do it just the same way you do with any other tables:
left jointhe tables (this time, the table with itself) and check fornull(missing rows).See it on db<>fiddle here