Update multiple rows in one table with differing values from another

user48408

I have the following 3 tables. The 1st table has about 100 rows. How can I update the CompanyId in the first table with its corresponding value from the 3rd table via one update statement?

T1
-----------------------------
FileId | CompanyId
-----------------------------
ABC      | NULL  
DEF      | NULL

T2
-----------------------------
FileId  | UserId
-----------------------------
ABC       | 123  
DEF       | 456

T3
-----------------------------
UserId  | CompanyId
-----------------------------
123       | V1  
456       | V2
Galma88

Use this statement:

UPDATE T1
SET COMPAYID = T3.CompanyId
FROM T1 INNER JOIN T2 ON T1.FILEID = T2.FILEID
        INNER JOIN T3 ON T2.USERID = T3.USERID

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Update specific rows from one table to another

From Dev

MYSQL - UPDATE multiple rows from another table

From Dev

Update multiple columns in one table based on values in another table in mysql

From Dev

Update MYSQL Table from multiple rows in another table

From Dev

Update multiple rows in table with values from a temporary table

From Dev

Javascript - Check values from one table and update another one

From Dev

How to update rows that were deleted from one table in the another?

From Dev

Update multiple columns of a table using aggregate values from another table

From Dev

Update multiple columns of a table using aggregate values from another table

From Dev

JQuery: How to drag multiple rows from one table to another?

From Dev

select multiple column from one table and insert into another as rows

From Dev

Insert multiple rows with single a query from one table into another in Oracle

From Dev

JQuery: How to drag multiple rows from one table to another?

From Dev

Join multiple values from one column, selected from another table

From Dev

How to extract multiple rows from a table based on values from multiple columns from another table and then concatenate in SQL?

From Dev

How to split a single row into multiple rows, each with their own cell values for the differing columns in Excel table

From Dev

Select rows from one table and adjust the values based on rows in another table

From Dev

Update all rows on table based on value from other table that gets multiple values from third table

From Dev

Subtract rows of one table from another table

From Dev

Update multiple rows in a table with different values

From Dev

How to update one table from another table?

From Dev

update one table from another selected table

From Dev

MySQL - Update table values from another table

From Dev

inserting table values from one table to another

From Dev

MySQL: Update rows in table, from rows with matching key in another table

From Dev

MySQL - Select multiple rows from one table whose IDs are stored in another table

From Dev

How to get multiple values from a template and update multiple rows in a table? Django

From Dev

mysql - move rows from one table to another

From Dev

How to copy rows from one table to another?

Related Related

  1. 1

    Update specific rows from one table to another

  2. 2

    MYSQL - UPDATE multiple rows from another table

  3. 3

    Update multiple columns in one table based on values in another table in mysql

  4. 4

    Update MYSQL Table from multiple rows in another table

  5. 5

    Update multiple rows in table with values from a temporary table

  6. 6

    Javascript - Check values from one table and update another one

  7. 7

    How to update rows that were deleted from one table in the another?

  8. 8

    Update multiple columns of a table using aggregate values from another table

  9. 9

    Update multiple columns of a table using aggregate values from another table

  10. 10

    JQuery: How to drag multiple rows from one table to another?

  11. 11

    select multiple column from one table and insert into another as rows

  12. 12

    Insert multiple rows with single a query from one table into another in Oracle

  13. 13

    JQuery: How to drag multiple rows from one table to another?

  14. 14

    Join multiple values from one column, selected from another table

  15. 15

    How to extract multiple rows from a table based on values from multiple columns from another table and then concatenate in SQL?

  16. 16

    How to split a single row into multiple rows, each with their own cell values for the differing columns in Excel table

  17. 17

    Select rows from one table and adjust the values based on rows in another table

  18. 18

    Update all rows on table based on value from other table that gets multiple values from third table

  19. 19

    Subtract rows of one table from another table

  20. 20

    Update multiple rows in a table with different values

  21. 21

    How to update one table from another table?

  22. 22

    update one table from another selected table

  23. 23

    MySQL - Update table values from another table

  24. 24

    inserting table values from one table to another

  25. 25

    MySQL: Update rows in table, from rows with matching key in another table

  26. 26

    MySQL - Select multiple rows from one table whose IDs are stored in another table

  27. 27

    How to get multiple values from a template and update multiple rows in a table? Django

  28. 28

    mysql - move rows from one table to another

  29. 29

    How to copy rows from one table to another?

HotTag

Archive