Solved

Delete script

Posted on 2011-02-22
4
341 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now