我有以下sql:
SELECT `id` FROM `exchange` WHERE `photo` = 1 ORDER BY `id` DESC LIMIT 18
我怎样才能得到不同的location
值?
例如这样做但它返回一个错误:
SELECT `id`, distinct(`location`) FROM `exchange` WHERE `photo` = 1 ORDER BY `id` DESC LIMIT 18
示例表:
id location
1 7
2 8
3 4
4 4
5 2
6 32
示例结果(当 LIMIT 5 时):
6,5,4,2,1