Last active
August 29, 2015 14:07
-
-
Save ranraj/839036349ff03481eb53 to your computer and use it in GitHub Desktop.
Queries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Select duplicate key on an column in mysql table with count | |
SELECT name, COUNT(*) c FROM CAT GROUP BY name HAVING c > 1; | |
## Simple table join queries | |
select a.* from CAT a,TAX b where b.name like '%Tax%' and a.PARENT_TAX_PKEY=b.pkey; | |
## Safe mode update Enable / Disable | |
SET SQL_SAFE_UPDATES = 0; | |
## Delete duplicate name records and keep lowest id record | |
DELETE n1 FROM CAT n1, CAT n2 WHERE n1.PKEY < n2.PKEY AND n1.name = n2.name; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment