I have statement like this one :
SELECT
COUNT(*)AS will
FROM
ae_orders o
LEFT JOIN
ae_orders_items oi ON oi.order_uid = o.uid
WHERE
po_date >= '2016-01-01' AND po_date <= '2016-01-31' AND status_text LIKE '%wil%'
This query is a count(*) so the result is only one field. But i would like to execute this query 6-7 time in one time changing only the (like '%will%') part of this statement and get the result of each count side by side.
Wanted result :
I try left join, full join like this
(
SELECT
COUNT(*) AS will
FROM
ae_orders o
LEFT JOIN
ae_orders_items oi ON oi.order_uid = o.uid
WHERE
po_date >= '2016-01-01' AND po_date <= '2016-01-31' AND status_text LIKE '%wil%'
) AS will
LEFT JOIN
(
SELECT
COUNT(*) AS will
FROM
ae_orders o
LEFT JOIN
ae_orders_items oi ON oi.order_uid = o.uid
WHERE
po_date >= '2016-01-01' AND po_date <= '2016-01-31' AND status_text LIKE '%phi%'
) AS phil
I'm not really sure this is possible. If someone have a solution.
Solution
After reading some of your comments i found an other way to get and display my data.
Here is the statement to get my solution.
SELECT
'Will' AS USER,
COUNT(*) AS TOTAL
FROM
ae_orders o
LEFT JOIN
ae_orders_items oi ON oi.order_uid = o.uid
WHERE
po_date >= '2016-01-01' AND po_date <= '2016-01-31' AND status_text LIKE '%wil%'
UNION
SELECT
'Phil' AS USER,
COUNT(*) AS TOTAL
FROM
ae_orders o
LEFT JOIN
ae_orders_items oi ON oi.order_uid = o.uid
WHERE
po_date >= '2016-01-01' AND po_date <= '2016-01-31' AND status_text LIKE '%phi%'
UNION
SELECT
'Peter' AS USER,
COUNT(*) AS TOTAL
FROM
ae_orders o
LEFT JOIN
ae_orders_items oi ON oi.order_uid = o.uid
WHERE
po_date >= '2016-01-01' AND po_date <= '2016-01-31' AND status_text LIKE '%Pet%'
Instead of getting result side by side i get result one above the other.