I am trying to learn SQL and wondering if something like this possible.
Select *
from RDInfo RD
right outer join RDCollection RDC
on (RDC.RDInfoID = RD.RDInfoID and RDC.IsReceived = 1
and RDC.IsRenewed = 0) or -- RDInfoID not in table RDC
I am trying to get data from RDCollection if it satisfies 3 conditions written in the braces if not RDInfoID does not have a record in RDC table. This is in Sql 2005.
I hope i am clear. I am not sure if this is the right away. Thank you very much for the help. Thanks!
So here, All Employees may or may not have a record in Department, so in that case, how can
Just use a left join instead of a right.
By using left outer join entries from RDInfo are returned regardless of whether or not there’s a match for RDCollection. When there isn’t a match the columns from RDCollection contain nulls.