Hi I want to query unique records using distinct in mysql but the problem is that it only returns a single column, how can I make it return all?
Here's my initial query:
SELECT distinct(country_name)
FROM HST_LOCATION
WHERE person_id='1897'
ORDER BY date_updated DESC
group by country_name
The GROUP BY
clause makes that column distinct, there's no need to use the DISTINCT
modifier. Just select all the columns and you should get what you want.
SELECT *
FROM HST_LOCATION
WHERE person_id = '1897'
GROUP BY country_name
ORDER BY date_updated DESC
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.