Friday, 15 June 2012

mysql - copy data of perticular id from one table and paste at perticular id of another table -



mysql - copy data of perticular id from one table and paste at perticular id of another table -

i have problem: have tables examp1 , examp2. want re-create info of examp1 id=138 , paste table examp2 @ id=5. tried

insert examp1 (rates,publishprice,name) select rates,publishprice,name examp2 id=138;

and

insert examp1 (rates,publishprice,name) id=5 select rates,publishprice,name examp2 id=138;`

but getting problem in 2nd query. while in 1st query info of id=138 copied not @ particular id.

if id 5 not exist in examp1, perhaps want:

insert examp2(id, rates, publishprice, name) select 5, rates, publishprice, name examp1 id = 138;

if ids both exist, want update:

update examp2 cross bring together (select e1.* examp1 e1 id = 138 ) e1 on examp2.id = 5 set e2.rates = e1.rates, e2.publishprice = e1.publishprice, e2.name = e1.name;

or this, based on question is.

mysql

No comments:

Post a Comment