Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Can you swap two values in SQL in one statement?
For instance, if I have records with an "order" value, and want to swap six and five around so that six becomes five and five becomes six, can I do it in one statement?
I'm not in a position to test this at the moment.
I was thinking you'd have to temporarily set the "order" value five to null, or a million or something, then make six into five and the temporarily-changed record into six.
Because if you do it like this:
then you're just going to end up with two sixes, aren't you? And if you do "limit =1" then you don't know which one you're going to get.set order = 5 where order = 6 set order = 6 where order = 5
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: non-perl SQL question
by Roger (Parson) on Dec 31, 2003 at 05:28 UTC | |
by tachyon (Chancellor) on Dec 31, 2003 at 05:55 UTC | |
by CountZero (Bishop) on Dec 31, 2003 at 08:22 UTC | |
by Roger (Parson) on Dec 31, 2003 at 11:59 UTC | |
by rkg (Hermit) on Dec 31, 2003 at 12:18 UTC | |
by CountZero (Bishop) on Jan 01, 2004 at 22:48 UTC | |
by Anonymous Monk on Jul 09, 2004 at 21:56 UTC | |
Re: non-perl SQL question
by tachyon (Chancellor) on Dec 31, 2003 at 05:37 UTC | |
Re: non-perl SQL question
by dbwiz (Curate) on Dec 31, 2003 at 12:55 UTC |
Back to
Seekers of Perl Wisdom