I need to delete all public messages older than a year where Users (message owners, senders) must be from Australia and 21 years old.
I get an error:
***#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 ‘inner join User inner join City inner join Country where Message.messa’ at line 2***.
My texts do not cover even a half of the task, so if anyone could help me here.
Here is my code:
delete
from Message
inner join User
inner join City
inner join Country
where Message.message_type=0 and
datediff(curdate(),Message.posted) >366 and
User.user_id=Message.owner_id and
datediff(User.date_of_birth,
str_to_date('1/01/1991', '%m/%d/%Y')) < 366 and
City.city_id=User.city_id and
Country.country_id=City.country_id and
Country.name='Australia'
this is because
Useris a reserved keyword in MySQL so you need to back lit it with quotesUser:alternatively if you are putting joining condition in
WHEREclause then no need to useINNER JOIN: