Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Delete query where = sub-query

Posted on 2009-06-29
2
Medium Priority
?
551 Views
Last Modified: 2013-12-07
Hello,
I'm trying to delete all the rows from table A where the Acc num matches the same account number from table B.

Tried the 23 queries below but they don't want to run

Any one know how to correct them?

First Attempt
 
DELETE A.*
FROM A, B
WHERE A.ACC_NUM=B.ACC_NUM=
 
Second Attempt
 
DELETE A.*
FROM A
WHERE A.ACC_NUM=(SELECT ACC_NUM
                                    FROM B);

Open in new window

0
Comment
Question by:ShockUK
[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 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 24734488
use IN instead of =
DELETE A.*
FROM A
WHERE A.ACC_NUM IN (SELECT ACC_NUM
                                    FROM B);

Open in new window

0
 
LVL 5

Expert Comment

by:mnialon
ID: 24734495
DELETE
FROM A
WHERE A.ACC_NUM IN (SELECT ACC_NUM
                                    FROM B);
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

618 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