MySQL - UPDATE query based on SELECT Query

后端 未结 11 2072
既然无缘
既然无缘 2020-11-21 23:58

I need to check (from the same table) if there is an association between two events based on date-time.

One set of data will contain the ending date-time of certain

11条回答
  •  时光说笑
    2020-11-22 00:53

    UPDATE
        `table1` AS `dest`,
        (
            SELECT
                *
            FROM
                `table2`
            WHERE
                `id` = x
        ) AS `src`
    SET
        `dest`.`col1` = `src`.`col1`
    WHERE
        `dest`.`id` = x
    ;
    

    Hope this works for you.

提交回复
热议问题