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
Back to
Seekers of Perl Wisdom