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
Thursday, July 17, 2014
check duplication of a column value in MySQL
To find the duplicate username in users table in MySQL:
SELECT username, COUNT(*) c
FROM `users`
GROUP BY username
HAVING c> 1
To get more detail information
SELECT firstname, lastname, username
FROM `users`
WHERE username IN
(
SELECT username
FROM `users`
GROUP BY username
HAVING COUNT(*) > 1
)
Labels:
MySQL
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment