Reputation: 49
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
Upvotes: 1
Views: 532
Reputation: 1715
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
Upvotes: 3