我有两个表,products(product_id) 和 sex(product_id,sex_id)。我正在尝试从具有 product_id 的两个表中删除行,以便在 sex 表中存在具有此 product_id 和 sex=1 的行。到目前为止我有
CREATE TEMPORARY TABLE tempTable
SELECT p.product_id
FROM products AS p
INNER JOIN sex AS s
ON p.product_id = s.product_id
WHERE s.sex = 1;
DELETE FROM products AS p
NATURAL JOIN tempTable AS t
DELETE 查询抛出此错误:
#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 'NATURAL JOIN tempTable AS t' at line 2
此 SELECT 查询工作正常:
SELECT * FROM products
NATURAL JOIN tempTable
为什么 SELECT 查询有效,但 DELETE 查询无效?