I have table A, 3 columns
id text1 text2
I have table B, 4 columns
id A_id key value
Data in table B looks like
id A_id key value
1 1 text1 test_value1
2 1 text2 test_value2
Each row in table A maps to 2 rows in table B. And columns text1 and text2 on table A are empty right now. I am trying to copy data from table B to table A.
How can I do that in 1 stament? Thanks. Right now I have below statement but have to specify
AND B.key = "text1"
, how can I update columns text1 and text2 in the same time?
UPDATE A
INNER JOIN B
ON A.id = B.A_id
AND B.key = "text1"
SET A.text1 = B.value