How to find "NOT IN" records in tables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2023 04:24 PM
Hello All,
I have 2 tables. Lets say Table A and Table B. Need to find the records available in Table A which is not available Table B through some join query using scripts without looping. What could be the best way to do it? Thank you in advance
thanks
Bala

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2023 04:50 PM
How are table a and table b related? Is there a reference field that joins them? is it just the data in the table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2023 04:55 PM
thank you for the reply. let say column name as APPLICATIONS. need to find applications not available in table B.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2023 05:16 PM
So table a and table b both have a column called APPLICATIONS and they are only related by the value that is stored in that column in each table? If so then @Murthy Ch solution is one way to go about it.
You could also try using a join but think thats only going to give you wants in both and you want a NOT
GlideRecord | ServiceNow Developers
If there is a small number of records, say 1000 in each you could use two arrays and then do a diff between them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2023 05:00 PM
thank you. Yes. Array is an other option. But thought there could be a way in query,