怎么用一句sql查询三个表并输出三个表的内容

来源:百度知道 编辑:UC知道 时间:2024/06/06 17:16:34
表一:table1 字段:id , title , content ,s_time
表二:table2 字段:id , title_a , content ,time
表三:table3 字段:id , title , content ,time

如题,按时间排序混合输出三个表的内容.

select table1.id,table1.title,table1.content ,table1.s_time from table1
union select table2.id , table2.title_a , table2.content ,table2.time
from table2
union select table3.id , table3.title , table3.content ,table3.time from table3
order by s_time

肯定正确啦^_^

将3个表连起来,用select ...
where table1.id=table2.id=table3.id;

三个表之间有关联吗,有关联的话可以采纳楼上的写法