Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Re: non-perl SQL question

by tachyon (Chancellor)
on Dec 31, 2003 at 05:55 UTC ( [id://317843]=note: print w/replies, xml ) Need Help??


in reply to Re: non-perl SQL question
in thread non-perl SQL question

Clever solution!

my $sql = sprintf "UPDATE table SET id = %d - id WHERE id IN ( %d, %d +)", ($val1+$val2), $val1, $val2; mysql> select * from test; +------+------+ | id | num | +------+------+ | 1 | 100 | | 2 | 200 | +------+------+ 2 rows in set (0.00 sec) mysql> UPDATE test SET id = 3 - id WHERE id IN (1,2); Query OK, 2 rows affected (0.00 sec) Rows matched: 2 Changed: 2 Warnings: 0 mysql> select * from test; +------+------+ | id | num | +------+------+ | 2 | 100 | | 1 | 200 | +------+------+ 2 rows in set (0.00 sec) mysql>

cheers

tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://317843]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-03-28 16:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found