postgres 更新一个表的字段值等于另一个表的字段值

PostgreSql表更新时,两个表只允许一个表起别名,一般是被更新的表不起别名,查询的表起别名

SQL的寫法是:

update t_check_task_video_backup
set car_number = t_check_logistics_trailer.license_number
from t_check_order as t_check_order , t_check_logistics_trailer as t_check_logistics_trailer, t_check_nvr as t_check_nvr
where t_check_task_video_backup.task_id = t_check_order.id
and t_check_order.trailer_id =t_check_logistics_trailer.id
and  t_check_logistics_trailer.nvr_id = t_check_nvr.id
and t_check_task_video_backup.download_path is null 

這樣就可以了

postgres 更新一个表的字段值等于另一个表的字段值_第1张图片

你可能感兴趣的:(解决问题,postgres,postgresql,sql,数据库)