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.
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
Post a Comment