I have a table, customer. The following is the sql statement and its output:
select C.ID, C.FNAME, C.LNAME, C.DATE
FROM CUSTOMER C
WHERE C.ID = 1007
3 John Smith 2005-10-05 00:00:00.000
4 Mary Brown NULL
5 Bill White NULL
And another table, account_detail, with about 30 records in there.
The following is the sql statement to join these two tables and its output:
select C.ID, C.FNAME, C.LNAME, AD.AMOUNT AS BONUS
from CUSTOMER C join account_detail AD on (C.ID = AD.REFERENCE)
where C.ID = 1007 and AD.TRANS_TYPE = 'BR'
3 John Smith 10.0000
In order to include all record in customer table, I used an outer join. Here is the sql statement and it out put:
select C.ID, C.FNAME, C.LNAME, AD.AMOUNT AS BONUS
from CUSTOMER C left join account_detail AD on (C.ID = AD.REFERENCE)
where C.ID = 1007 and AD.TRANS_TYPE = 'BR'
3 John Smith 10.0000
The output is exactly the same as the one from previous inner join. I added an 'outer' to make it a "left outter join" but the output remained the same.
I changed to use the legacy outer join as the following:
select C.ID, C.FNAME, C.LNAME, AD.TRANS_AMOUNT AS BONUS
from CUSTOMER C, account_detail AD
where C.ID *= AD.REFERENCE and C.ID = 1007 and AD.TRANS_TYPE = 'BR'
and I got the right result:
3 John Smith 10.0000
4 Mary Brown NULL
5 Bill White NULL
Can anyone tell me why the legacy outer join statement works but the ANSI-92 outer join sql statement fails?
Did I do something wrong or I fail to set up some system configuration?
Your help is much appreciated!
select C.ID, C.FNAME, C.LNAME, C.DATE
FROM CUSTOMER C
WHERE C.ID = 1007
3 John Smith 2005-10-05 00:00:00.000
4 Mary Brown NULL
5 Bill White NULL
And another table, account_detail, with about 30 records in there.
The following is the sql statement to join these two tables and its output:
select C.ID, C.FNAME, C.LNAME, AD.AMOUNT AS BONUS
from CUSTOMER C join account_detail AD on (C.ID = AD.REFERENCE)
where C.ID = 1007 and AD.TRANS_TYPE = 'BR'
3 John Smith 10.0000
In order to include all record in customer table, I used an outer join. Here is the sql statement and it out put:
select C.ID, C.FNAME, C.LNAME, AD.AMOUNT AS BONUS
from CUSTOMER C left join account_detail AD on (C.ID = AD.REFERENCE)
where C.ID = 1007 and AD.TRANS_TYPE = 'BR'
3 John Smith 10.0000
The output is exactly the same as the one from previous inner join. I added an 'outer' to make it a "left outter join" but the output remained the same.
I changed to use the legacy outer join as the following:
select C.ID, C.FNAME, C.LNAME, AD.TRANS_AMOUNT AS BONUS
from CUSTOMER C, account_detail AD
where C.ID *= AD.REFERENCE and C.ID = 1007 and AD.TRANS_TYPE = 'BR'
and I got the right result:
3 John Smith 10.0000
4 Mary Brown NULL
5 Bill White NULL
Can anyone tell me why the legacy outer join statement works but the ANSI-92 outer join sql statement fails?
Did I do something wrong or I fail to set up some system configuration?
Your help is much appreciated!