Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 09-01-2013, 07:29 PM   #1
LQ Newbie
Registered: Mar 2013
Posts: 12

Rep: Reputation: Disabled
Question Sql delete entries

Hi All,

I was trying to delete all entries from a table whose corresponding id number entries are not found in a associated different table.

If I want to display all entries of a table1 (using id_number) which are not present in the other table I used this and it worked perfectly.
SELECT * from table1 WHERE id_number NOT IN (SELECT id_number FROM TABLE2)

However when I use the delete command it doesn't work
DELETE * from table1 WHERE id_number NOT IN (SELECT id_number FROM TABLE2)

Please could some one correct where am I doing wrong?

Old 09-01-2013, 07:48 PM   #2
Senior Member
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
syntax: delete from table_name where condition. see DELETE.
DELETE from table1 WHERE id_number NOT IN (SELECT id_number FROM TABLE2)
1 members found this post helpful.
Old 09-02-2013, 03:19 AM   #3
Senior Member
Registered: Sep 2012
Posts: 1,385

Rep: Reputation: 274Reputation: 274Reputation: 274
As said by Berhanie, your syntax is wrong.
The correct statement is "delete from table_name", not "delete * from table_name".


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
can't delete arp entries YaMaHaBoB Linux - Networking 1 06-23-2011 08:16 AM
How can I delete one of my Blog entries? catkin LQ Suggestions & Feedback 12 05-18-2011 02:43 AM
How do I delete entries from grub? joseph2020 Ubuntu 5 02-17-2011 10:09 PM
How to delete LDAP entries struggled_newbie Linux - Newbie 1 11-03-2009 02:56 AM
Delete all entries in the calendar in Evolution TheSpork Linux - Software 0 04-16-2004 08:51 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:52 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration