So I kinda realized it too late but I need to have another column on one of my tables that has the group id of each row.
The data looks like this:
Code Description Group(currently empty)
1 Test
2 Test
1 Test
3 Test
3 Test
What the column group contain should be
Code Description Group(currently empty)
1 Test 56
2 Test 57
1 Test 56
3 Test 58
3 Test 58
Can this be done through UPDATE?
Thank you in advance.
2
Answers
If the version of the database is
8.0+
, then you can use a window function such asDemo
For Mysql versions prior to 8.0, we can use a user variable to generate the numbers. Here is the code written and tested in workbench.