On Thu, 23 Sep 2004 11:03:08 +0100, wrote:
>Hi, > >I want to swap the data in two fields > >eg > t1.beds to t1.beds2 >and > t2.beds2 to t1.beds > do I need to store one of the fields temporarily?
Hey chums you normally get me an answer in minutes, is my question too easy? zzapper (vim, cygwin, wiki & zsh) --
zzapper, Gee, have you paid your bill yet?<g>
The only thing I've been able to come up with is:
update table1 a, table1 b set a.beds1=b.beds2, a.beds2=b.beds1 where a.rcd_id=b.rcd_id
You need to create a transitory value for one of the variables and this is done by joining the table onto itself (the "b" table won't get updated as table "a" gets updated). This solution should work on any column type.
There is probably a faster more efficient way of doing it (without a table join), but only if we knew what the column types were. If they were String then perhaps subscripting out the strings would be possible.
Mike
P.S. Now about your bill... :)
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]