Skip to content

Instantly share code, notes, and snippets.

@garsaud
Created November 2, 2020 10:51
Show Gist options
  • Save garsaud/ea73ac4a66c8cffeb79f56933cb8bdc4 to your computer and use it in GitHub Desktop.
Save garsaud/ea73ac4a66c8cffeb79f56933cb8bdc4 to your computer and use it in GitHub Desktop.
Record duplicate counts in a column
update mytable t1
join (select field, count(*) as dup_count from mytable group by field) t2
set t1.count_field = dup_count
where t1.field = t2.field
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment