实现从数据库多个相同表结构的表同时查询

2025-04-29 20:57:20
推荐回答(4个)
回答1:

num 是我随便写的一个他们需要做条件的列名。具体按照你自己的列名来写。
test_Table 这个是给联合起来查询的表取的一个别名,随便你写什么名字都行。

select max(num)
from (
select num from TABLE_2010
union
select num fromTABLE_2011
union
select num from TABLE_2012
) as test_Table

回答2:

select max(列名) from TABLE_2010,TABLE_2011,TABLE_2012

回答3:

用union试试。
另外,取最大值可以用max

回答4: