0

I have 2 table, in table A I have id_A and region_A, in table 2 I have id_B and region_B

I want to set region_A = region_B when id_A is equal id_B

I read this question

and tried :

UPDATE  A  SET  A.`region` =   B.region  
FROM  A   
inner join B    on A.id_a = B.id_b 

I got this error

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT * FROM A inner join B on A.id_a' at line 1

How can update my table A ?

Community
  • 1
  • 1
parik
  • 2,313
  • 12
  • 39
  • 67

1 Answers1

1

This is SQL Server syntax. Try this instead:

UPDATE Α AS t1
INNER JOIN Β AS t2
    ON t1.region = t2.region
SET t1.id_a = t2.id_b
Giorgos Betsos
  • 71,379
  • 9
  • 63
  • 98