CharlieT
CharlieT

Reputation: 414

MySql Delete not working

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

Upvotes: 0

Views: 548

Answers (3)

Gordon Linoff
Gordon Linoff

Reputation: 1269553

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.

Upvotes: 0

Mahesh Madushanka
Mahesh Madushanka

Reputation: 2988

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 ....

Upvotes: 2

dcc310
dcc310

Reputation: 1076

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

Upvotes: 1

Related Questions