LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 09-01-2013, 08:29 PM   #1
wackysiya
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?

Thanks
 
Old 09-01-2013, 08:48 PM   #2
Berhanie
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.
Code:
DELETE from table1 WHERE id_number NOT IN (SELECT id_number FROM TABLE2)
 
1 members found this post helpful.
Old 09-02-2013, 04:19 AM   #3
kooru
Senior Member
 
Registered: Sep 2012
Posts: 1,385

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

http://www.w3schools.com/sql/sql_delete.asp
 
  


Reply


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 09:16 AM
How can I delete one of my Blog entries? catkin LQ Suggestions & Feedback 12 05-18-2011 03:43 AM
How do I delete entries from grub? joseph2020 Ubuntu 5 02-17-2011 11:09 PM
How to delete LDAP entries struggled_newbie Linux - Newbie 1 11-03-2009 03:56 AM
Delete all entries in the calendar in Evolution TheSpork Linux - Software 0 04-16-2004 09:51 AM


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

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