ccb_bee 发表于 2008-07-01 15:56

求助:如何从两张表中同时取数据

两张表的结构一样,
select * from tab1 where date="20080701" order by date;
select * from tab2 where date="20080701" order by date;

我想用一个语句就完成以上功能,请问该如何写这个sql?

xxyyy 发表于 2008-07-01 17:16

回复 #1 ccb_bee 的帖子

滤掉重复行:
select * from tab1 where date="20080701" order by date;
union
select * from tab2 where date="20080701" order by date;

保留所有行:
select * from tab1 where date="20080701" order by date;
union all
select * from tab2 where date="20080701" order by date;
页: [1]
查看完整版本: 求助:如何从两张表中同时取数据