On Thu, 23 Sep 2004 13:31:03 -0500, wrote: >At 10:04 AM 9/23/2004, you wrote: >>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... :) Mike, cheque in the post! Sorry about my impertinence, I think I'm going to be a coward and create an extra column for the transitory value, as it's a one off operation. Just had a thought (dangerous I know) but couldn't I just rename the fields as that would do the same thing?
zzapper (vim, cygwin, wiki & zsh) -- vim -c ":%s%s*%CyrnfrTfcbafbeROenzSZbbyranne%|:%s)[R-T]) )Ig|:norm G1VGg?" http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]