Answer the question
In order to leave comments, you need to log in
How to make something like this: v = 0 UPDATE FROM t SET `menuindex` = v++;?
I have a table with a lot of data. I can sort it in the database, but I need to add the initial menu indexing, which will change over time. v = 0 UPDATE FROM t SET `menuindex` = v++;
where v is an integer type
t is a table
as it is executed, the value will increase by 1.
Excuse: I don't know how to formulate a query in search engines...
Answer the question
In order to leave comments, you need to log in
What dialect of SQL?
For mysql: stackoverflow.com/questions/6617056/updating-colum...
For postgresql... However, by the characteristic ` in the column name, I think that you have mysql.
According to the link type such a solution:
SET @v := 0;
UPDATE FROM t SET `menuindex` = @v := @v+1;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question