Adsense
Popular Posts
- MySQL workbench -"Could not decrypt password cache"
- peer review (3)
- PHP, dump varailbes in a format way
- "Unusual traffic from your computer network" from blogger
- Install APXS in Redhat Linux
- JavaScript, remove trailing insignificant zeros after toFixed function
- Update member directory
- Set Windows path command line
- JavaScript: add days to current date
- DataTable table order by numeric, not by text
Wednesday, July 16, 2014
select distinct for composite key in MySQL using GROUP BY
For example,we have users table and containing firstname and lastname.
We can select distinct lastname using:
SELECT DISTINCT lastname FROM users
What happen if we want to see distinct of combination of firstname and lastname?
We can use GROUP BY as following
SELECT lastname, firstname FROM users GROUP BY lastname, firstname
Labels:
MySQL
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment