0
這是我的數據我可以用MySQL加入COUNT嗎?
newCatCols
=====
id sku name
---------------
1 4001 Black
2 4031 Red
3 4021 Black
4 4041 Blush
products
=====
id sku Price
---------------
1 4001 123
2 4031 232
3 4021 453
4 4041 233
這是我的查詢
SELECT COUNT(*) AS numTotal
FROM `products`
INNER JOIN `colors` ON `products`.`sku` = `colors`.`sku`
WHERE (
`name` = 'Apple_Black'
OR `name` = 'Black'
OR `name` = 'Black_Aubergine'
OR `name` = 'Black_Blush'
OR `name` = 'Black_Slate'
OR `name` = 'Black_Turquoise'
OR `name` = 'Red_Black'
OR `name` = 'Sapphire_Black'
OR `name` = 'Multi Apple'
)
AND `status` = '1'
AND `category` = 'sig'
GROUP BY `products`.`sku`
ORDER BY `products`.`rank` ASC
理想的情況下,如果我只是改變這一行是完美SELECT COUNT(*) AS numTotal
不知何故只修改,使其工作?數據當前返回行值爲1的產品列表,因此它只是循環而不計算所有行的總值。
這是應只顯示在返回總數,4例如應顯示
Output
=====
numTotal
---------------
4
是什麼你想要的輸出? – RedFilter
你究竟想要什麼?你能發佈你想要的結果嗎? –
已更新,它應該只返回查詢中的總值。目前它只是循環所有項目 – TheBlackBenzKid