i am trying to create a database view to show records from table a but not exists in table b using left join
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2017 02:07 PM
Hi,
I have two tables with similar column names and I need to return records from the left table which are not found in the right table
I know how to write this in SQL Server but not familiar with ServiceNow Left Join any help would be really appreciated..
SELECT a.*
FROM TableA a
LEFT JOIN TableB b
ON b.col1 =a.col2
WHERE b.col1 is NULL
What i need in ServiceNow is
SELECT a.*
FROM Change_Request a
LEFT JOIN sysapproval_approver b
ON b.sysapproval =a.SYS_ID
WHERE b.sys_id is NULL
Please advise...
Thanks in advance..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2017 05:27 PM
To create a table with a left join:
- From the Database View form, click New on the View Tables related list.
- Configure the form and add the Left join field (a check box) to the form.
- Click Save.
- Complete the form and select the Left join check box.
- Selecting Left join causes the left-hand table in the database view to display all records, even if the join condition does not find a matching record on the right-hand table. Select this check box for view tables that specify a Where clause. Selecting Left join for view tables without a Where clause does not affect the query.
- Joined tables are ordered left to right from lowest to highest Order values.
- Click Submit.
- Personalize the View Tables related list to show the Left join column.
- Click a record to view a table.
- The View Table form appears.
- To add an OR to your where clause use ||.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2017 05:54 AM
This is giving me like inner join(matching records from both the tables)
I need left outer join, Records exists only in TableA but not in Table B
Thanks in advance..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2017 05:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2017 06:15 AM
Hi,
from what I know, left outer join is not available, but you can reach the desired result by:
- Creating a database view, setting the left join option as true
- Filtering results in a list or report, excluding records with a match in table b (table b columns filled in).
- Remaining records exist only in TableA but not in Table B
Regards,
Valentina