Solved

Delete script

Posted on 2011-02-22
4
348 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

632 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