table a contains:
ID: 1 Name: X
2 y
3 z
table B contains:
ID:1 name:
2
2
May i know how to copy the name from table a to table b and what will happen to to table b containing the same id.
table a contains:
ID: 1 Name: X
2 y
3 z
table B contains:
ID:1 name:
2
2
May i know how to copy the name from table a to table b and what will happen to to table b containing the same id.
Try to update table b.
Update b1
set b1.name=a1.name
from b b1
join a a1 on a1.id=b1.id
If table b is contain same id then same name updated.
Try to use UPDATE
in following without joining tables:
UPDATE table_a a
SET Name = ( SELECT Name
FROM table_b b
WHERE b.id = a.id )
Or you can do It by joining tables in following:
UPDATE a
SET a.Name = b.Name
FROM table_a a
JOIN table_b b ON a.id = b.id
already id values are present in tableb so you have to use use update statement for copying name column values.
update tableb b set name= (select a.name from tablea a
inner join
tableb b
on
a.id=b.id)
This is for MysqL
Update b as b1 inner join a as a1 on a1.id=b1.id
set b1.name=a1.name