0

I have a mysql delete script which gives me 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 'LEFT JOIN mall ON mall.m_id = unifo.mids WHERE mallnames = 'My Mall'' at line 2

Delete query:

DELETE FROM unifo 
LEFT JOIN mall ON mall.m_id = unifo.mids 
WHERE mallnames = 'My Mall' && time_insert < NOW( ) - INTERVAL 25 
MINUTE 

I cannot find my mistake

3 Answers 3

2

you have a basic issue in this query

DELETE FROM unifo 
LEFT JOIN mall ON mall.m_id = unifo.mids 
WHERE mallnames = 'My Mall' && time_insert < NOW( ) - INTERVAL 25 
MINUTE

your performing a left join with mall table and then base on mall value your going to delete something but in left join mallname can be null no point of left joining it

2 specify the table

DELETE unifo FROM unifo ....

Sign up to request clarification or add additional context in comments.

Comments

1

You may need to say which table you are deleting from, as in this answer: Delete with Join in MySQL

Comments

0

You have two tables in the from, but do not specify which to delete from.

I would recommend uses table aliases as well:

DELETE u
    FROM unifo u LEFT JOIN
         mall m
         ON m.m_id = u.mids 
WHERE mallnames = 'My Mall' AND time_insert < NOW( ) - INTERVAL 25 MINUTE ;

This assumes that you want to delete the rows from unifo.

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.