Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Left outer join with GlideRecord

Panagiotis Kons
Tera Expert

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

 

6 REPLIES 6

The above will return the related lists... Let me try it and see if it helps.

 

Thank you

 

Panos

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