Skip to content

Instantly share code, notes, and snippets.

@iegik
Last active September 16, 2019 12:04
Show Gist options
  • Select an option

  • Save iegik/b1a4b3d9bd093a999fcc to your computer and use it in GitHub Desktop.

Select an option

Save iegik/b1a4b3d9bd093a999fcc to your computer and use it in GitHub Desktop.

Set ordinal number from #1 for data group #6

select @rownum := 0;
update a set a.orderid = @rownum:=@rownum+1 where a.groupid = 6;
groupid orderid
6 1
6 2

Data Types

column name type example
id int(11) unsigned Autoincrement
created_at datetime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment