I have two tables, both looking like
id name value
===================
1 Joe 22
2 Derk 30
I need to copy the value of value
from tableA
to tableB
based on check name in each table.
Any tips for this UPDATE
statement?
I have two tables, both looking like
id name value
===================
1 Joe 22
2 Derk 30
I need to copy the value of value
from tableA
to tableB
based on check name in each table.
Any tips for this UPDATE
statement?
If you have common field in both table then it's so easy !....
Table-1 = table where you want to update. Table-2 = table where you from take data.
--Store your data in temp table Select * into tempTable from table1
--Now Update the column UPDATE table1 SET table1.FileName = (select FileName from tempTable where tempTable.id = table1.ID);
you need to join the two tables:
for instance you want to copy the value of
name
from tableA intotableB
where they have the sameID
UPDATE 1
UPDATE 2
Second possibility is,
The second option is feasible also if you're using safe updates mode (and you're getting an error indicating that you've tried to update a table without a WHERE that uses a KEY column), by adding:
In addition to this answer if you need to change tableB.value according to tableA.value dynamically you can do for example: