1

So I'm trying to run the following code to delete a record from a table when thhe customer ID is 100

DELETE FROM workoutplan
JOIN account ON workoutplan.Account_Username = account.Username
JOIN customer ON account.Customer_idCustomer = customer.idCustomer
WHERE Customer_idCustomer = 100

However I get the following error

[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'JOIN account ON workoutplan.Account_Username = account.Username
JOIN customer O' at line 2
1
  • 1
    The error shows * FROM workoutplan ... but your example shows only DELETE FROM workoutplan. Do you by chance have DELETE * FROM workoutplan in your actual code? Commented Jun 30, 2015 at 23:45

1 Answer 1

3
DELETE workoutplan 
FROM   workoutplan w 
       JOIN account 
         ON w.account_username = account.username 
       JOIN customer 
         ON account.customer_idcustomer = customer.idcustomer
WHERE  customer_idcustomer = 100 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.