sql - PostgreSQL 使用内连接删除

标签 sql postgresql

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/

相关文章:

python - 加速 Django 数据库函数以对缺失值进行地理插值

sql-server-2008 - postgresql中如何编写索引查询

sql - 如果列表包含表 b 中另一列的子字符串,则使用表 b 中列的值更新列表

eclipse - 是否可以调试 PL/Java(最好从 Eclipse 调试)?

sql - 如何在 MySQL 中执行 FULL OUTER JOIN?

SQL Server 到 mySQL 转换器

java - 如何在 HQL 或 JPQL 中使用强制转换?

mysql - SQL 数据库 : use one table with 3, 5M 条目或条目较少的许多表?

java - 如何获取 .txt 或 .sql 文件的编码类型

postgresql - 如何检查何时创建了 postgres 触发器?