MySQL Forums
Forum List  »  PHP

Multiple selects in one statement
Posted by: Radu Enea
Date: February 14, 2021 07:12AM

Hello,

Let's say that I have a table like this:

|id |orders |
|----|-------------|
|1 |one |
|2 |two |
|3 |three |
|4 |two |
|5 |four |
|6 |one |
|7 | two |


I want to make one select in order to count orders column but to group by orders values. Something like:

one -> 2,
two -> 3,
three -> 1,
four -> 1

Eventually in a array
Array
(
[0] => Array
(
[0] => one
[1] => 2
)

[1] => Array
(
[0] => two
[1] => 3
)

[2] => Array
(
[0] => three
[1] => 1
)
[4] => Array
(
[0] => four
[1] => 1
)
)

Thanks

Options: ReplyQuote


Subject
Written By
Posted
Multiple selects in one statement
February 14, 2021 07:12AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.