Re: Multiple selects in one statement
Posted by:
Radu Enea
Date: February 14, 2021 12:48PM
What I do is:
$query = "SELECT
DATE_FORMAT(OrderDate, '%d %M %Y (%a)') as dateCreated,
count(*) AS numbers
FROM new_orders
WHERE (OrderDate BETWEEN '$substr' AND '$today')
GROUP BY DAY(OrderDate)
ORDER BY OrderDate DESC
With this statement I have the number of orders for each day.
But in order column (cart) I have different unique values, but some of them have the same words.
For exemple in cart column I have
- Freedom,10,4,3,<img=........
- click2call
- smartwifi,4,10,<img=....
- click2call
- Freedom,10,3,1,<img......
etc
I want to group those orders by date (day) and values from cart
I try something like
$query = "SELECT
DATE_FORMAT(OrderDate, '%d %M %Y (%a)') as dateCreated,
count(*) AS numbers
FROM new_orders
WHERE (OrderDate BETWEEN '$substr' AND '$today')
GROUP BY DAY(OrderDate), cart LIKE '%Click2call%', cart LIKE '%freedom%'
ORDER BY OrderDate DESC
As a result I want to have:
[0] => Array
(
[dateCreated] => 14 February 2021 (Sun)
[click2call] => 10
[freedom] => 13
)
[1] => Array
(
[dateCreated] => 13 February 2021 (Sat)
[click2call] => 15
[freedom] => 6
)
etc.
Thanks in advance