I'm having a small problem making a Join between two tables in SQL, I'd like to know if you can help me.
There are 2 tables GTM_ITEM_CLASSIFICATION and ITEM_REFNUM , both refer to the ITEM table, but using different keys. For the first table, the GTM_ITEM_GID field is used and the ITEM_GID field is used for the second table.
What happens is that when there is a Insert User
named "ADMIN" in the first table (GTM_ITEM_GID), I need to retrieve in the other table which is the corresponding registry for ADMIN. This second table is an attribute table. For the type of users I want, I need to use a filter of ITEM_REFNUM_QUAL_GID = 'PC_CODE_APPROVER'
However, when you apply the following select
,
SELECT * FROM GTM_ITEM_CLASSIFICATION G
LEFT JOIN ITEM_REFNUM R
ON G.GTM_ITEM_GID = R.ITEM_GID
WHERE G.GTM_ITEM_GID IN ('1','2')
AND R.ITEM_REFNUM_QUAL_GID = 'PC_CODE_APPROVER'
The only record I see is 1 , whereas I'd like it to display the 2 records (the second with a null reference next to it).
Do you know if it is possible to make a select
that returns all records, and those that do not exist in the second table return as null to me?!