0
我有這樣的MySQL查詢:如何轉換並修復codeigniter的查詢?
SELECT *
FROM store_product
LEFT JOIN store_promo_product ON store_product.store_product_id = store_promo_product.store_product_id
LEFT JOIN store_promo ON store_promo.store_promo_id = store_promo_product.store_promo_id
JOIN product ON product.product_id = store_product.product_id
WHERE store_product.store_id = 338 and store_promo_product.store_product_id=52
雖然我知道如何使用加入語法將其轉換爲codeigniter
活動記錄,問題是,有時候,我可以從同一家商店有幾個"store_product_id"
所以查詢將返回產品詳細信息+促銷詳情兩次或更多(取決於我爲同一產品推出多少促銷活動)。我正在尋找只有一個產品(因爲它是相同的產品)與兩個促銷(因爲他們是不同的促銷銷售)..
希望我解釋了我的自我。 甚至純mysql
當然會做,如果可能的話。
'LIMIT 1'?.... – Pogrindis
看看'GROUP BY' –
好吧,考慮我只想要一個產品的所有宣傳片..(記住我可以有一個產品的幾個宣傳片) – Dror