1
我需要選擇每個品牌類別的五種最新產品,然後顯示按類別分組的結果。需要按類別選擇5個最新記錄?
MySQL數據庫看起來像;
表product
:
product_id (pk)
product_name
product_etc
product_publish_date
brand_id (fk)
表brand
brand_id (pk)
brand_name
結果應該出來像下面...
brand_a product k
brand_a product a
brand_a product h
brand_a product l
brand_a product 33
brand_b product h
brand_b product z
brand_b product 9
brand_b product ddd
brand_b product a
試圖與
SELECT * FROM產品 GROUP BY brand_id ORDER BY product_publish_date LIMIT 5 – Adrian 2011-12-15 04:39:41