Mysql: auto increment one column based on another column -


please problem in mysql. how change auto increment different value if 1 of column has same value.. example

when inserting new value in table. if x_id 1 id 1 , on. if x_id 2 my id 1 .. (id auto increment.)

this expected reult.

enter image description here

sorry bad english. thank you. :)

if understand correctly, want calculate x_id. if so, need column specifies ordering of rows.

then, 1 method use correlated subquery:

select t.id,        (select count(*) t t2 t2.id = t.id , t2.?? <= t.??) x_id t; 

the ?? column specifies ordering.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -