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
Hi Kevin,
It works in mysql but not exactly as I need.
In my case it copied content of column2 into column1.
So, not exactly what I intended to achieve.
Thanks.
Igor
update mydata set column1 = column2, column2 = column1
On Thu, Sep 23, 2010 at 12:03 AM, Kevin (Gmail) kfoneil...@gmail.comwrote:
I ran these commands:
use test
DROP TABLE IF EXISTS mydata;
CREATE TABLE mydata (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,column1
CHAR(1),column2 CHAR(2));
INSERT INTO mydata (column1,column2) VALUES ('a','z'), ('b','y'), ('c','x'),
('d','w'), ('e','v');
SELECT * FROM mydata;
UPDATE mydata A
Couldn't you just rename the columns?
JW
On Wed, Sep 22, 2010 at 11:53 AM, Rolando Edwards
redwa...@logicworks.netwrote:
I ran these commands:
use test
DROP TABLE IF EXISTS mydata;
CREATE TABLE mydata (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,column1
CHAR(1),column2 CHAR(2));
INSERT
What about:
select `id`, `column1` as 'column2', `column2` as 'column1';
Steve
On Wed, 2010-09-22 at 13:06 -0500, Johnny Withers wrote:
Couldn't you just rename the columns?
JW
On Wed, Sep 22, 2010 at 11:53 AM, Rolando Edwards
redwa...@logicworks.netwrote:
I ran these commands:
Hi Rolando,
This is perfect solution I was looking for.
Why do you use left join here? It looks like inner join works fine as well.
Thanks.
Rolando Edwards wrote:
I ran these commands:
use test
DROP TABLE IF EXISTS mydata;
CREATE TABLE mydata (id INT NOT NULL AUTO_INCREMENT PRIMARY
Hi Rolando,
This is perfect solution I was looking for.
Why do you use left join here? It looks like inner join works fine as well.
Thanks.
Rolando Edwards wrote:
I ran these commands:
use test
DROP TABLE IF EXISTS mydata;
CREATE TABLE mydata (id INT NOT NULL AUTO_INCREMENT PRIMARY
This is even better!
JW
On Wed, Sep 22, 2010 at 2:27 PM, Steve Staples sstap...@mnsi.net wrote:
What about:
select `id`, `column1` as 'column2', `column2` as 'column1';
Steve
On Wed, 2010-09-22 at 13:06 -0500, Johnny Withers wrote:
Couldn't you just rename the columns?
JW
-
From: Egor Shevtsov [mailto:nixofort...@googlemail.com]
Sent: Wednesday, September 22, 2010 4:14 PM
To: MySQL mailing list
Subject: Re: Swap data in columns
Hi Rolando,
This is perfect solution I was looking for.
Why do you use left join here? It looks like inner join works fine as well.
Thanks
update mydata set column1 = column2, column2 = column1
(works in sqlserver, can't try mysql at the moment)
You can select which rows by adding a where clause obviously.
I suppose that the field values are copied to a buffer which is the written
to the table at the end of the update (or row by
10 matches
Mail list logo