Question

SQL DELETE falling over in PHPmyAdmin. Can't work out why; is it because of LEFT OUTER JOIN?

SELECT * 
  FROM `User` 
LEFT OUTER JOIN `freshersdata` ON `User`.`username`=`freshersdata`.`username` 
 WHERE (`freshersdata`.`username` IS null) 
   AND (`User`.`Persistent`!=1)

This SQL query is falling over with ( #1064 - You have an error in your SQL syntax; ) message but works perfecly with a SELECT instead of a delete, why is this?

Was it helpful?

Solution

You have to specify from which table you want to delete:

For example from User:

DELETE User.* 
  FROM User 
LEFT OUTER JOIN freshersdata ON User.username=freshersdata.username 
 WHERE (freshersdata.username IS null) AND (User.Persistent!=1)

OTHER TIPS

DELETE FROM User 
LEFT OUTER JOIN 
   freshersdata ON User.username=freshersdata.username  
WHERE (freshersdata.username IS null) AND (User.Persistent!=1)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top