0
我有一个表称为TableName
我想delete
所有行,他们的产品质量的SUM
小于2 我需要inner join
表oc_order_product
和SUM
值具有相同product_id
然后使用WHERE子句中这SUM
值delete
所有行与SUM
小于2 我使用下面的查询现在:如何使用和与内部连接在一个delete语句
Delete TablenName from TablenName
INNER JOIN oc_order_product
ON oc_order_product.product_id = TablenName.product_id
where oc_order_product.quantity HAVING SUM(oc_order_product.quantity) < 2;
对此我收到以下错误:
#1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax
to use near 'HAVING SUM(oc_order_product.quantity) < 2' at line 4
谢谢你,你也可以告诉我,如果我可以添加'WHERE oc_order_status.order_status_id IN(“3”,“5”,” 17','19','20','23','25','26','29')'。对不起,我刚才发现我也需要这个,如果你愿意,我可以将它添加到问题中。 – Schwann
@Swann。 。 。因为这涉及第三个表格,所以你应该提出另一个问题。 –
我没有编辑这个问题,并通过以下链接发布了一个新问题[http://stackoverflow.com/questions/43861288/how-to-use-sum-and-inner-join-in-a-delete-声明和添加一个第三表到它],我将不胜感激那一个答案。 – Schwann