Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help Rewrite Query

Author  Topic 

zwheeler
Starting Member

25 Posts

Posted - 2012-01-06 : 12:43:25
I have the following query and it works
I would like to rewrite this query as an outer joing but i donot know how. I wouild like help in rewriting the query.
Basically, i just want to return records that do not exists in
F47FirmCommitment but do exists in mf_insured_loan.



select distinct fk_fha_number,mf_insured_loan.date_firm_commitment
from mf_insured_loan, F47FirmCommitment
where (fk_fha_number <> FHACaseNumber)
and mf_insured_loan.date_firm_commitment is null

Thanks in advance

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-06 : 12:49:00
SELECT l.* FROM mf_insured_loan l
LEFT JOIN F47FirmCommitment r
ON l.key = r.key
ON fk_fha_number = FHACaseNumber
WHERE r.Key IS NULL -- this needs to be the key in the right (r.) table

(not sure which column is in which table...always label all your columns for future references and self documentation)

What are the join keys between the 2 tables...you don't show it in your query...which BTW really doesn't work correctly

Oh...ok

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -