To preface this question - I know I'm missing something really obvious here but it is Friday afternoon!
I'm trying to COUNT to number of times certain values appear within the same column and produce a table of the results.
Here's my code so far:
MYSQL
SELECT COUNT(order_status) as printed
FROM orders WHERE order_status = 'Printed Order'
UNION
SELECT COUNT(order_status) as charged
FROM orders WHERE order_status = 'Charged Order'
UNION
SELECT COUNT(order_status) as exchanged
FROM orders WHERE order_status = 'Exchanged Order'
UNION
SELECT COUNT(order_status) as refunded
FROM orders WHERE order_status = 'Refunded Order'
UNION
SELECT COUNT(order_status) as cancelled
FROM orders WHERE order_status = 'Cancelled Order'
GROUP BY order_status
Result of the above query
printed
-------
224
19190
593
2618
2899
The code is producing the correct figures, however, I would prefer the result to look as follows:
Desired result
printed - 224
charged - 19190
exchanged - 593
refunded - 2618
cancelled -2899
This way I can easily reference them via associative array call i.e. $order_status['printed']
Any help would be great.