I have two tables
shoemaster
DataFix
In the DataFix
table, I need to update size number by comparing two tables size and genderid.
shoemaster
:
productsizeid size genderId
---------------------------------
114 6 800
115 6.5 800
103 6 801
104 6.5 801
DataFix
table:
size genderId sizeno
-------------------------
6 800 Null
6.5 800 Null
6 801 Null
I need to write update query for DataFix
table sizeno
from shoemaster
based on genderid
and size
values comparing to update the second (DataFix
) table.
sizeno
should update like below output of DataFix table:
output-DataFix Table
size genderId sizeno
6 800 114
6.5 800 115
6 801 104
Please help me to write update query
CodePudding user response:
UPDATE T SET
T.sizeno=X.sizeno
FROM DataFix AS T
JOIN shoemaster AS X ON T.SIZE=X.SIZE AND T.genderId=X.genderId