Adsense
Popular Posts
- Code update from PHP 7.4 to PHP 8.1 - PhpSpreadsheet
- MySQL workbench -"Could not decrypt password cache"
- Code update from PHP 7.4 to PHP 8.1 - Worksheet/Iterator.php
- Rendering HTML tags inside textarea
- axios handle blob type data
- Unix Utils and wget in Windows
- increase mysql query speed
- Setup vi syntax for PHP
- EXCEL return to the next line in the same cell
- Get WAMP running on EC2
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