I am using outer join, I have two tables tblaccount with 33 records and tblcustchannelacct with 146 records, and I am writing a query to have only tblaccounts matching records with tblcustchannelacct, so only 33 records should come, but no matter how much I change the query I get 146 records.
Queries are below:
*-Select tab1.ACCOUNT_ID, tab2.ACCOUNT_ID
from tblaccount tab1, tblcustchannelacct tab2
where tab1.account_id (+) = tab2.account_id;
Here I used (+) in the WHERE clause for tblaccount to include all the rows that is tblaccount but 146 i.e.: tblcustchannelacct no. of records are showing.
Now I used outer join with keyword of 'outer join' instead of (+)
from tblcustchannelacct tab2
left join tblaccount tab1
on tab1.ACCOUNT_ID= tab2.ACCOUNT_ID
LEFT JOIN keyword returns all rows from the left table tblaccount, even if there are no matches in the right table tblcustchannelacct.
(but showing the same 146 records of tblcustchannelacct).