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 |
syntax: delete from table_name where condition. see DELETE.
Code:
DELETE from table1 WHERE id_number NOT IN (SELECT id_number FROM TABLE2) |
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 |
All times are GMT -5. The time now is 03:54 PM. |