当前位置: 代码迷 >> Sql Server >> 怎么在三个同样schema表中查找
  详细解决方案

怎么在三个同样schema表中查找

热度:103   发布时间:2016-04-27 16:41:25.0
如何在三个同样schema表中查找?
大家好,我的问题如下:

我有三个同样schema的表,假设是T1,   T2,   T3,   每个都是关于股票信息的,只不过不同的表包含的是不同地区的股票,主键PKey在三个表中都不会有相同的,我想进行这样的查找:

对一个主键,在三个表中查找,肯定能找到一个结果,不过不知道怎么写SQL,哪位教我一下?谢谢。



------解决方案--------------------
select * from (select * from t1 union select * from t2 union select * from t3)t
where t.pkey=值
------解决方案--------------------
select * from t1 where pk=pkvalue
union select * from t2 where pk=pkvalue
union select * from t3 where pk=pkvalue;
  相关解决方案