1

I have two tables.

table_a table_b

idA idB nameA nameB remarkA1 remarkB remarkA2

Update from Comment: Code I have tired

UPDATE table_b 
SET remarkB = table_a.remarkA1 
FROM table_a WHERE table_b.id = table_a.id 

But this code I can only update one value to column remarkB,If i want update values in table_b from table_a by update values from remarkA1, remarkA2 to remarkB How should I write?

Bear_Seul
  • 15
  • 6
  • Does both the tables have any connection? How are the two tables linked to each other? Any query which you have tried? – G one Jul 05 '17 at 03:42
  • @Gone the table don't have connection. I tired yo update by UPDATE table_b SET remarkB = table_a. remarkA1 FROM table_a WHERE table_b.id = table_a.id But this code i can update one value to column remarkB, if I want remarkB have two value from remarkA1 , remarkA2 . I can write or not? – Bear_Seul Jul 05 '17 at 04:18

1 Answers1

0

You can use the following Update Statement along with you need a string CONCAT

I'm assuming the data type of table_a.remarkA1 and table_a.remarkA2 are string (i.e., VARCHAR)

UPDATE table_b
SET remarkB = CONCAT(table_a.remarkA1, ' ', table_a.remarkA2)
FROM table_a
WHERE table_b.idB = table_a.idA   
B.Balamanigandan
  • 4,713
  • 11
  • 68
  • 130