Quantcast
Channel: Auto-increment MySQL column field on update using a single query - Stack Overflow
Browsing all 4 articles
Browse latest View live

Answer by deeps for Auto-increment MySQL column field on update using a...

SET @ordering = 100000;UPDATE candidate SET regno = (@ordering := @ordering + 1) WHERE year = 2014 AND confirm = 1 AND e_stat = 1 ORDER BY centre_code, `name`;

View Article



Answer by nico gawenda for Auto-increment MySQL column field on update using...

Update a table while sub-selecting the same table is not possible: http://dev.mysql.com/doc/refman/5.6/en/update.html"Currently, you cannot update a table and select from the same table in a...

View Article

Answer by Gordon Linoff for Auto-increment MySQL column field on update using...

This might do what you want:update table set increment = (select cnt from (select count(*) as cnt from table t where field = 'value' and t.id <= table.id ) a ) where field = 'value';

View Article

Auto-increment MySQL column field on update using a single query

Suppose I have this code:$ids = execute_query("SELECT id FROM table WHERE field = 'value' ORDER BY order_field");$query = "UPDATE table SET increment = CASE";for ($i = 0; $i <= sizeof($ids); $i++) {...

View Article
Browsing all 4 articles
Browse latest View live




Latest Images