Skip to content

Instantly share code, notes, and snippets.

@eatgrass
Last active November 18, 2016 02:15
Show Gist options
  • Save eatgrass/c056f4c2171ada6aa70fa728ff46782a to your computer and use it in GitHub Desktop.
Save eatgrass/c056f4c2171ada6aa70fa728ff46782a to your computer and use it in GitHub Desktop.
MySql snippets
select
nickname, count(id) as cnt
from
customer
group by
nickname having cnt > 1
update login a,
(select a.id
from login a,
(select email, count(id) as num
from login
group by email
having count(id) >= 2) b
where a.email = b.email) b
set a.email = concat(a.id, '@old-email.local')
where a.id = b.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment