MySQL-基于SELECT查询的更新查询我需要检查(从同一个表)是否存在基于日期时间的两个事件之间的关联。一组数据将包含特定事件的结束日期时间,另一组数据将包含其他事件的开始日期时间。如果第一个事件在第二个事件之前完成,那么我想将它们链接起来。到目前为止,我得到的是:SELECT name as name_A, date-time as end_DTS, id as id_A
FROM tableA WHERE criteria = 1SELECT name as name_B, date-time as start_DTS, id as id_B
FROM tableA WHERE criteria = 2然后我加入他们:SELECT name_A, name_B, id_A, id_B, if(start_DTS > end_DTS,'VALID','') as validation_checkFROM tableALEFT JOIN tableB ON name_A = name_B然后,我可以根据我的Validation_CHECK字段运行一个带有SELECT嵌套的更新查询吗?
3 回答
慕田峪7331174
TA贡献1828条经验 获得超13个赞
UPDATE `table1` AS `dest`, ( SELECT * FROM `table2` WHERE `id` = x ) AS `src`SET `dest`.`col1` = `src`.`col1`WHERE `dest`.`id` = x;
添加回答
举报
0/150
提交
取消