您好我想在mysql中使用distinct查询唯一记录,但问题是它只返回一个列,如何让它全部返回?
这是我的初步查询:
SELECT distinct(country_name)
FROM HST_LOCATION
WHERE person_id='1897'
ORDER BY date_updated DESC
group by country_name
答案 0 :(得分:0)
GROUP BY
子句使该列不同,不需要使用DISTINCT
修饰符。只需选择所有列,您就可以获得所需的内容。
SELECT *
FROM HST_LOCATION
WHERE person_id = '1897'
GROUP BY country_name
ORDER BY date_updated DESC