Speaking of collaboration, http://stackoverflow.com/questions/1167885/update-sql-with-consecutive-numbering says you can do it using mysql5, like
SET @a:=10; UPDATE table SET table.ID=@a:=@a+1 WHERE table.ID=5

In sqlite I employ limit

#!/usr/bin/perl -- use strict; use warnings; use DBI; use DBD::SQLite; use Data::Dump qw/ dd /; unlink 'goner.sqlite'; my $dbh = DBI->connect( "DBI:SQLite:database=goner.sqlite", undef, undef, {qw/RaiseError 1/} ); eval { $dbh->do('CREATE TABLE NameId ( ID INTEGER , Name TEXT );'); $dbh->do(q!INSERT INTO NameID ( ID, Name ) VALUES ('1','bar');!); $dbh->do(q!INSERT INTO NameID ( ID, Name ) VALUES ('2','bar');!); $dbh->do(q!INSERT INTO NameID ( ID, Name ) VALUES ('5','FEE');!); $dbh->do(q!INSERT INTO NameID ( ID, Name ) VALUES ('5','FII');!); $dbh->do(q!INSERT INTO NameID ( ID, Name ) VALUES ('5','FOO');!); } or warn "$@"; dd( $dbh->selectall_arrayref('select * from NameID' ) ); dd( $dbh->selectrow_array(q{ select COUNT(*) from NameID WHERE ID='5' + } ) ); #~ http://www.sqlite.org/compile.html#enable_update_delete_limit #~ https://www.sqlite.org/lang_update.html #~ https://dev.mysql.com/doc/refman/5.0/en/update.html my $sql = qq{ UPDATE NameID SET ID=? WHERE ID='5' LIMIT 1 }; my( $count ) = $dbh->selectrow_array(q{ select COUNT(*) from NameID W +HERE ID='5' } ); my $nid = 10; while( $count ){ dd({ rowsaffected => $dbh->do( $sql, {}, $nid ) }); dd( $dbh->selectall_arrayref('select * from NameID' ) ); $nid++; $count--; } undef $dbh; unlink 'goner.sqlite'; __END__ [[1, "bar"], [2, "bar"], [5, "FEE"], [5, "FII"], [5, "FOO"]] 3 { rowsaffected => 1 } [[1, "bar"], [2, "bar"], [10, "FEE"], [5, "FII"], [5, "FOO"]] { rowsaffected => 1 } [[1, "bar"], [2, "bar"], [10, "FEE"], [11, "FII"], [5, "FOO"]] { rowsaffected => 1 } [[1, "bar"], [2, "bar"], [10, "FEE"], [11, "FII"], [12, "FOO"]]

In reply to Re^2: Increase a value inside MySQL query using perl by Anonymous Monk
in thread Increase a value inside MySQL query using perl by AhmedABdo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.