Cummings, Shawn (GNAPs) wrote:

If I have 4 Fields (FIELD1, FIELD2, FIELD3 & FIELD4)....

I can do this easily;

UPDATE TABLE_NAME SET FIELD4 = FIELD1;

But -- how do I do it so that FIELD4 = FIELD1 & FIELD2 ??? I can't seem to find any examples online. Maybe it's just too early in the morning - I'm drawing a blank! ;)

This depends on the data types, if you want to set FIELD4 to be FIELD1 +
FIELD2 with integers:

UPDATE table_name SET FIELD4 = (FIELD1 + FIELD2);

If they are strings:

UPDATE table_name SET FIELD4 = CONCAT(FIELD1,' ',FIELD2);

If you are swapping values:

UPDATE table_name SET FIELD4 = (@tmp:=FIELD4), FIELD4 = FIELD1, FIELD1 =
@tmp;

Best regards

Mark

--
Mark Leith, Support Engineer
MySQL AB, Worcester, England, www.mysql.com
Are you MySQL certified?  www.mysql.com/certification



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to