Left outer join with GlideRecord
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2023 03:36 AM
Hello,
I'm trying to join two tables (A & B). Table B has a reference to table A, but not the other way round. With a JOIN query I would normally do
SELECT * FROM A, B where B.ID_THAT_REFERENCES_A = A.ID
This would give me all the records in A that have a corresponding record in B.
However I would like to get all records in A that do not have a corresponding record in B. Wiwth SQL I would do the following
SELECT * FROM A LEFT OUTER JOIN B ON B.ID_THAT_REFERENCES_A = A.ID WHERE B.ID_THAT_REFERENCES_A IS NULL
I am trying to do the same with a GlideRecord in Service now, but for some reason I am not getting the correct results. I'd appreciate any help/pointers on the correct syntax.
Regards
Panos
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2023 05:03 AM
The above will return the related lists... Let me try it and see if it helps.
Thank you
Panos
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2023 05:39 AM
OK, I just tried it, it doesn't work. It is correctly returning records from table A that have no related lists in table B, however the query still returns records from table A that are linked to table B (table B has a reference to them).
Any more thoughts?
Regards
Panos