我有一個MySQL查詢從多個表中提取數據。其中一個字段是可以在結果中多次出現的customer_id。有沒有一種方法可以將字段附加到結果中,以顯示每個唯一customer_id在結果集中出現的次數?因爲它代表我的查詢如下...計算結果中出現字符串的次數
SELECT customer.customer_id, customer.name, customer.email, Date_format(orders.datetime,'%d-%m-%Y') AS order_date, order_items.order_item_id, order_items.order_id
FROM order_items, product, orders, customer
WHERE order_items.product_id = product.product_id AND product.manufacturer = 'Nike' AND order_items.order_id = orders.order_id AND orders.customer_id = customer.customer_id ORDER BY customer_id, order_date
非常感謝
簡單而有效。感謝您的幫助 – Jules 2013-04-11 12:59:52
不用擔心伴侶 – 2013-04-11 13:01:16