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