Populating database table column with corresponding values from another table in PostgreSQL

后端 未结 1 1526
长情又很酷
长情又很酷 2021-01-27 10:46

Table 1 is \'z_scrapestorm_rentals\' and table 2 is \'pcpao_cols\'. They both have address columns named \'address_1_line_trunc\' and \'address_one_line\' respectively.

1条回答
  •  孤城傲影
    2021-01-27 11:13

    Okay, so I answered my own question and inserted the web_strap values from the other table into the target table by using the following query:

    UPDATE z_scrapestorm_rentals
        SET web_strap = pcpao_cols.web_strap
        FROM
            pcpao_cols
        WHERE Z_scrapestorm_rentals.address_1_line_trunc 
    ILIKE pcpao_cols.address_one_line
        RETURNING pcpao_cols.web_strap;
    

    What was missing from my original query I detailed in my question's "method 1" was the RETURNING keyword.

    0 讨论(0)
提交回复
热议问题