Answer the question
In order to leave comments, you need to log in
How to make such query with GROUP BY?
Good afternoon!
There is a table in the db:
and a query using GROUP BY:
SELECT id FROM `table` GROUP BY value ORDER BY id DESC
array(2) {
[0]=>
array(1) {
["id"]=>
string(1) "1"
}
[1]=>
array(1) {
["id"]=>
string(1) "3"
}
}
array(2) {
[0]=>
array(1) {
["id"]=>
string(1) "5"
}
[1]=>
array(1) {
["id"]=>
string(1) "4"
}
}
Answer the question
In order to leave comments, you need to log in
SELECT id FROM (select id, value from `table` ORDER BY id desc) as tbl GROUP BY value
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question