Solved

Delete script

Posted on 2011-02-22
4
343 Views
Last Modified: 2012-05-11
I would like to delete values in one table that don't exist in another.

for example
delete from glf_chart_acct where accnbri does not exist in table glf_ldg_acc_trans
What would be the correct syntax for this?
0
Comment
Question by:Matthew34
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
rushShah earned 167 total points
ID: 34957790
try this,
delete 
from glf_chart_acct a
LEFT JOIN glf_ldg_acc_trans t ON a.accnbri = t.accnbri
where t.accnbri is null

Open in new window

0
 
LVL 24

Assisted Solution

by:jimyX
jimyX earned 333 total points
ID: 34957798
delete from glf_chart_acct where NOT EXISTS (select accnbri from table glf_ldg_acc_trans)
0
 
LVL 24

Assisted Solution

by:jimyX
jimyX earned 333 total points
ID: 34957813
or,
delete from glf_chart_acct where NOT EXISTS (select glf_ldg_acc_trans.accnbri from table glf_ldg_acc_trans where glf_ldg_acc_trans.accnbri = glf_chart_acct.accnbri)
0
 

Author Closing Comment

by:Matthew34
ID: 34957833
Thanks
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question