Possible duplicate:
Update row with data from another row in the same table
I created the table as
create table myTable (id INT, myData varchar(20));
And I have meanings like
insert into myTable VALUES
(1, 'Value 1'),
(2, 'Value 2'),
(3, 'Value 3');
Now I insert the line as
insert into myTable (id) values (4);
Now I want to insert the data for id 4. The value for id 4 is the same as id 3. SO I think I need to use the UPDATE statement.
I tried with below, however this will not work.
update myTable SET myData=(select myData FROM myTable WHERE id=3) WHERE id=4;
Please let me know what needs to be done.
Note
Actually, I have myData type as MEDIUMBLOB , however, for demo purpose, I used varchar.
user1203613
source
share