I have following UPDATE
query, but something is wrong when executing.
I'm trying to update values in table1 with values in table import_data, but I need the id from table ids... So the table ids links table1 and *import Simple, isn't it?
UPDATE table1
INNER JOIN import_data ON (
import_data.id = (
SELECT customer_id
FROM ids
INNER JOIN table1 ON (
table1.id = ids.link
)
WHERE ids.type = 'NORMAL'
)
)
SET table1.name = import_data.name;
table1
| id | name |
|----------|-----------|
| AA-00001 | Company 1 |
| AA-00002 | Company 2 |
| AA-00003 | Company 3 |
import_data
| id | name |
|--------|-------------------|
| 401000 | Updated company 1 |
| 401001 | Updated company 2 |
| 401002 | Company 3 |
ids
| link | id | type |
|----------|--------|--------|
| AA-00001 | 401000 | NORMAL |
| AA-00002 | 401001 | NORMAL |
| AA-00003 | 401002 | NORMAL |