Database View - Not In condition

Jaisankar
Tera Expert

Good day.

Would like to create a database view for the following condition. Please help on how to check "NOT In" in database views. 

  • Want to get list of products from sn_apm_trm_standards_product (t) that are not in cmdb_software_product_model (c).
    • t.product not in c.product

The NOT in condition is not working in database view. Please help.

Thanks

1 ACCEPTED SOLUTION

Team,

 

I could get left join for sn_apm_trm_standards_product table (i.e., all records from sn_apm_trm_standards_product irrespective of its match with other 2 tables) by marking left= true for other 2 tables as follows - It is bit strange though as marking Left=true for other 2 tables provides the left join output for table marked as Left = False.

 

Jaisankar_0-1749107587565.png

 

Thanks 

 

View solution in original post

4 REPLIES 4

Mark Manders
Mega Patron

Can you share what you already have and also what the requirement is? Because you need something common to show a record in a db view. 

Maybe a report with a related list condition can do the trick, 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Ankur Bawiskar
Tera Patron
Tera Patron

@Jaisankar  

database view is used to join 2 tables based on some common fields etc

Example left join in creating a database view 

Database View Left Join Help 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Jaisankar
Tera Expert

Thanks for the responses.
Making Left join for sn_apm_trm_standards_product (t) is not working. Keeping either of the tables as left always providing response considering  cmdb_software_product_model as left. Also, the left join is working when we keep the order sequence as same in both the tables. Tried the same where clause in both. The output remains the same. When the sequence is same, left join works only considering cmdb_software_product_model as left irrespective of which ever table we mark as left. When the sequence is different, left join is not working.
Please comment on this scenario. 

Jaisankar_0-1748876353934.png

Thanks

 

Team,

 

I could get left join for sn_apm_trm_standards_product table (i.e., all records from sn_apm_trm_standards_product irrespective of its match with other 2 tables) by marking left= true for other 2 tables as follows - It is bit strange though as marking Left=true for other 2 tables provides the left join output for table marked as Left = False.

 

Jaisankar_0-1749107587565.png

 

Thanks