欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

数据库多表共有属性关联查询,按各表时间属性排序

程序员文章站 2022-05-08 11:24:33
...

摘要表p_report_list:

数据库多表共有属性关联查询,按各表时间属性排序

要素表

p_report_videoperson:

数据库多表共有属性关联查询,按各表时间属性排序

p_report_videocar:

数据库多表共有属性关联查询,按各表时间属性排序

p_report_videomac:

数据库多表共有属性关联查询,按各表时间属性排序

p_report_videotext:

数据库多表共有属性关联查询,按各表时间属性排序

查询语句:

select * from (
    select person_id as id, patrol_id, location_id, person_picture_url as url, type, person_show_start_time as showtime from p_report_videoperson
    union all
    select car_id as id, patrol_id, location_id, car_picture_url as url, type, car_show_start_time as showtime from p_report_videocar
    union all
    select mac_id as id, patrol_id, location_id, mac_picture_url as url, type, mac_show_start_time as showtime from p_report_videomac
    union all
    select audio_id as id, patrol_id, location_id, audio_picture_url as url, type, audio_show_start_time as showtime from p_report_videotext
    ) as ref
where patrol_id = '540fa8bfc9e84224af803e8c9c84f4aa'
order by showtime 

查询结果:

数据库多表共有属性关联查询,按各表时间属性排序


相关标签: SQL 多表查询