MySQL Selecting and deleting whole entries I'm a total noob to mysql and i`m still trying to get my head around it. I need to select duplicate entries in a song DB and delete only those entries not in a category. I can get t to work with select. though there's an error but not with delete. Could someone help and point out my total noobness mistake?

Select Code

Select Songlist.ID,Artist,Title,Filename,CategoryID 
from Songlist,categorylist 
where Artist = "Lady Gaga" AND Title = "Bad Romance" AND  
(Categorylist.CategoryID &lt;&gt; 12)


Delete Code

Delete from * 
where Artist = "Lady Gaga" AND Title = "Bad Romance" AND  
Categorylist.CategoryID &lt;&gt; 12


Thanks in advance.
MySQL's DELETE syntax requires the table names involved in the DELETE.

However, I don't think the SELECT query is working as you want it to, either.

You have not established any connection between Songlist and Categorylist. So, it's going to give you a cross join - every row in Songlist wit the specified Artist and Title, matched with every row in Categorylist where CategoryID is not 12. If you had two matching rows in Songlist, and 11 matching rows in Categorylist, your result would be 22 rows.

Assuming you have a CategoryID in Songlist, you'd presumably want rows where the Songlist.CategroyID is not 12.

Try this:

Select Songlist.ID,Artist,Title,Filename,CategoryList.CategoryID 
  from Songlist
         LEFT OUTER JOIN Categorylist ON (Songlist.CategoryID = Categorylist.CategoryID)
 where Artist = "Lady Gaga"
   AND Title = "Bad Romance"
   AND (   Categorylist.CategoryID IS NULL
        OR Songlist.CategoryID &lt;&gt; 12
       )
;


This should find all records with your artist and title, where either there's no record in Categorylist with the CategoryID in Songlist, or where the CategoryID is something other than 12.

Then, the delete statement to delete those records from Songlist would be:

DELETE Songlist
  FROM Songlist
         LEFT OUTER JOIN Categorylist ON (Songlist.CategoryID = Categorylist.CategoryID)
 where Artist = "Lady Gaga"
   AND Title = "Bad Romance"
   AND (   Categorylist.CategoryID IS NULL
        OR Songlist.CategoryID &lt;&gt; 12
       )
;


Presumably, leaving only any rows with that artist and title where the CategoryID is 12.

NOTE: Code is, obviously, untested.