I was wondering if anyone had run into the following situation:
table_id | foreign_key1 | foreign_key2
I have rows that look like this:
1 | 1 | 2
1 | 1 | 3
..
The foreign_key2 is the unique value. What I would like to do is have a sequential count of where table_id and foreign_key1 are the same.
So for the above I would get something like:
1 | 1 | 2 | 1
1 | 1 | 3 | 2
In Oracle I could call the ROW_NUMBER() function. Is there anything similar to that in MySQL? My searches have only brought back stored procedures that won’t work for my situation.
it ~can~ be an auto_increment, and reset after each grouping, if that’s what you want, but they will be permanent, and renumbering them will be difficult
but if what you really want is just to number them in a query, then you should do that in the application code