ALTER TABLE tablename1 CHANGE column1 column2 VARCHAR(64), CHANGE column2
column1 VARCHAR(64)

Assuming the columns are varchar(64)


Jangita | +254 76 918383 | MSN & Y!: jang...@yahoo.com
Skype: jangita | GTalk: jangita.nyag...@gmail.com




-----Original Message-----
From: nixofortune [mailto:nixofort...@googlemail.com] 
Sent: 22 September 2010 6:30 PM
To: mysql@lists.mysql.com
Subject: Swap data in columns

Hi all.

Sorry for very simple question, just can't figure out the solution.
I need to swap data in column1 with data in column2.


+----+---------+---------+
| id | column1 | column2 |
+----+---------+---------+
|  1 | a       | z       |
|  2 | b       | y       |
|  3 | c       | x       |
|  4 | d       | w       |
|  5 | e       | v       |
+----+---------+---------+

Can you achieve this with a simple query?
so for id 1 column1 = 'z' and column2 = 'a' and so on.

Thanks guys,
Igor


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=arch...@jab.org

Reply via email to