1

I have 2 tables A and B. In table A I have a char column and integer column for many2one(ID) of column B.

In table B I have same char column.

Now i have to compare char columns of both tables and update the respecting ID of table B to table A.

Table A

| Name | ID of B |
|------|---------|
| ABC  |         |
| BCD  |         |
| CDF  |         |

Table B

| ID | Name |
|----|------|
|  1 | CDF  |
|  2 | ABC  |
|  3 | BCD  |

How to do this in UPDATE query, if not possible how to do that in INSERT query for whole table. Im having 100s of record in table.

Vanjith
  • 520
  • 4
  • 23
  • 1
    I've not tried it but probably you need something like: `UPDATE table_A SET table_A.ID = table_B.ID WHERE table_A.NAME = table_B.NAME` – cpinamtz Jun 12 '18 at 07:25
  • Thanks for ur comment. This is working.UPDATE A SET A.ID = B.id FROM B WHERE A.name = B.name; – Vanjith Jun 12 '18 at 09:44

0 Answers0