I’m trying to execute such command in mysql:
DELETE FROM product_description, product, product_to_store, url_alias WHERE
product_description.name LIKE '%|%' AND product.product_id =
product_description.product_id AND product_to_store.product_id =
product_description.product_id AND url_alias.query =
CONCAT('product_id=',product_description.product_id)
However it 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 'WHERE product_description.name LIKE '%|%' AND product.product_id = product_descr' at line 1
When I will replace ‘DELETE’ with ‘SELECT *’ query works like a charm.
According to mysql doc
Currently, you cannot delete from a table and select from the same
table in a subquery.
So now I’m stuck with no idea how to perform such query, without using PHP
EDITED
My final query that worked:
DELETE product_description, product, product_to_store, url_alias
FROM product_description, product, product_to_store, url_alias
WHERE product_description.name LIKE '%|%' AND product.product_id =
product_description.product_id AND product_to_store.product_id =
product_description.product_id AND url_alias.query =
CONCAT('product_id=',product_description.product_id)
So the tip was to add all 4 tables names just after DELETE to make it work, as JW wrote
you need to specify on which the delete should takes place, in this example below, the records will be deleted in table
product_descriptionOR use
ANSI SQL-92format