How to find "NOT IN" records in tables

Bala19
Tera Contributor

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

7 REPLIES 7

DrewW
Mega Sage
Mega Sage

How are table a and table b related?  Is there a reference field that joins them?  is it just the data in the table?

Bala19
Tera Contributor

thank you for the reply. let say column name as APPLICATIONS. need to find applications not available in table B.

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.

 

Bala19
Tera Contributor

thank you. Yes. Array is an other option. But thought there could be a way in query,