Record exist in one table but not in other 2 tables.

hi experts,
iam having 3 seperate tables . these 3 tables are interconnected with one key value.   i want the record exists in this table Loln_LnDisbmntPaymntDet  but not available in
 
this Lgen_HTHBankRevfeed_D_New  and this  Loln_BulklnPay  table how to write query.

      select * from Loln_LnDisbmntPaymntDet  where lnno='GYDM2SP1708120005'
      select * from Lgen_HTHBankRevfeed_D_New where ProposalNo ='GYDM2SP1708120005'
      select * from Loln_BulklnPay  where lnno='GYDM2SP1708120005'
kowsika deviAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vitor MontalvãoMSSQL Senior EngineerCommented:
SELECT * 
FROM Loln_LnDisbmntPaymntDet  p
WHERE p.lnno='GYDM2SP1708120005'
    AND NOT EXISTS (SELECT 1 FROM Lgen_HTHBankRevfeed_D_New n WHERE n.ProposalNo = p.Inno)
    AND NOT EXISTS (SELECT 1 FROM Loln_BulklnPay b WHERE b.Inno = p.Inno) 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
try use Left join like:

select a.*
from Loln_LnDisbmntPaymntDet a
left join (select * from Lgen_HTHBankRevfeed_D_New where ProposalNo ='GYDM2SP1708120005') b on a.key = b.key
left join (select * from Loln_BulklnPay  where lnno='GYDM2SP1708120005') c on a.key = c.key
where a.lnno='GYDM2SP1708120005'
and b.key is null
and c.key is null

Open in new window

0
kowsika deviAuthor Commented:
thanks vitor jj
0
kowsika deviAuthor Commented:
how can i implement in temp table jj

 UPDATE #templndetNew  set [INSTRUMENT UPDATION DETAILS]='Via DOL'
       FROM   #templndetNew T                               
join Loln_LnDisbmntPaymntDet  p on t.[PROPOSAL NO] =p.lnno where  
      NOT EXISTS (SELECT 1 FROM Lgen_HTHBankRevfeed_D_New n WHERE n.ProposalNo = p.LnNo )
    AND NOT EXISTS (SELECT 1 FROM Loln_BulklnPay b WHERE b.Lnno = p.lnno) and   [INSTRUMENT UPDATION DETAILS]=''
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
UPDATE T set [INSTRUMENT UPDATION DETAILS]='Via DOL'
       FROM   #templndetNew T                               
join Loln_LnDisbmntPaymntDet  p on t.[PROPOSAL NO] =p.lnno 
where  NOT EXISTS (SELECT 1 FROM Lgen_HTHBankRevfeed_D_New n WHERE n.ProposalNo = p.LnNo )
    AND NOT EXISTS (SELECT 1 FROM Loln_BulklnPay b WHERE b.Lnno = p.lnno)
    AND t.[INSTRUMENT UPDATION DETAILS]='' 

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.