gpt4 book ai didi

sql - PostgreSQL 使用内连接删除

转载 作者:行者123 更新时间:2023-11-29 13:53:36 25 4
gpt4 key购买 nike

DELETE B.* 
FROM m_productprice B
INNER JOIN m_product C ON B.m_product_id = C.m_product_id
WHERE C.upc = '7094' AND B.m_pricelist_version_id = '1000020'

我收到以下错误 PostgreSQL 8.2.11

ERROR:  syntax error at or near "B"
LINE 1: DELETE B.* from m_productprice B INNER JOIN m_product C ON ...

我试着给予

DELETE B from m_productprice B  INNER JOIN m_product C ON B....
ERROR: syntax error at or near "B"

我试着给予

ERROR:  syntax error at or near "INNER"
LINE 1: DELETE from m_productprice B INNER JOIN m_product C ON B.m_...

我的查询有什么问题?

最佳答案

DELETE 
FROM m_productprice B
USING m_product C
WHERE B.m_product_id = C.m_product_id AND
C.upc = '7094' AND
B.m_pricelist_version_id='1000020';

DELETE 
FROM m_productprice
WHERE m_pricelist_version_id='1000020' AND
m_product_id IN (SELECT m_product_id
FROM m_product
WHERE upc = '7094');

关于sql - PostgreSQL 使用内连接删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36366667/

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