gpt4 book ai didi

mysql - 为什么这个复杂的删除 SQL 查询不起作用?

转载 作者:行者123 更新时间:2023-11-29 06:43:27 26 4
gpt4 key购买 nike

我正在尝试实现一个“复杂”的 SQL 删除查询,但它不起作用。

这是我的查询:

DELETE
FROM Market_Commodity_Price_Series AS MC_PS
INNER JOIN MarketDetails_CommodityDetails AS MD_CD
ON MC_PS.market_commodity_details_id = MD_CD.id
INNER JOIN MarketDetails AS MD
ON MD_CD.market_details_id = MD.id
WHERE
MD.localization_id = 1

我只想删除 Market_Commodity_Price_Series 中的所有行,但具有此 WHERE 条件。正如您所看到的,where 条件使用一些 JOIN 操作。

问题是执行此查询时我收到此错误消息:

#42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS MC_PS INNER JOIN MarketDetails_CommodityDetails AS MD_CD ON MC_PS.mar' at line 2

我该如何解决这个问题?也许使用它作为子查询:

SELECT MC_PS.id
FROM Market_Commodity_Price_Series AS MC_PS
INNER JOIN MarketDetails_CommodityDetails AS MD_CD
ON MC_PS.market_commodity_details_id = MD_CD.id
INNER JOIN MarketDetails AS MD
ON MD_CD.market_details_id = MD.id
WHERE
MD.localization_id = 1

(使用 ID)

但如何呢?

最佳答案

您想删除MC_PS,因此请在删除丢失的“MC_PS”后写入

DELETE MC_PS
FROM Market_Commodity_Price_Series AS MC_PS
INNER JOIN MarketDetails_CommodityDetails AS MD_CD
ON MC_PS.market_commodity_details_id = MD_CD.id
INNER JOIN MarketDetails AS MD
ON MD_CD.market_details_id = MD.id
WHERE
MD.localization_id = 1

关于mysql - 为什么这个复杂的删除 SQL 查询不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50563414/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com