Need a update-query to populate table column "display_order"
I have a table on mysql with these columns:
- id
- property_id
- display_order
The data is to be like this:
1 , 1 , 1
2 , 1 , 2
3 , 1 , ...
3 , 2 , 1
4 , 2 , 2
5 , 2 , ...
but the display_order
is currently set to 1 on all rows.
I need a mysql query in order to set display_order
as given in the above example.
This a 1 to N realation ship
- property table
- photo table
... = 3 , 4 5 ...开发者_如何学Python N ( <-dysplay order)
I don't no how perform this update.
create an UPDATE with a @variable, give it an initial value ..., with case change ... to 1, 1 to 2 and 2 to ... and assign its value to the colunm, updating fields from a subselect ordered by the columns that form your key.
精彩评论