把两个表的查询结果生成一个表又怎么做? select ... into newtable from old1,old2 where ...
二表关联,然后合并相同字段的那一列,如何做?是不是要 select ...,old1.col1+old2.col1 as col1 from old1,old2 where ...
select A.a,A.b,A.other,B.other from A,B where A.a =B.a and A.b=B.b 楼主的意思是,字段关联的,且相等的,只取其中一个表的,不知我理解可对。 要生成一个新表: select A.a,A.b,A.other,B.other into #t from A,B where A.a =B.a and A.b=B.b
select col1 from table1 UNION ALL select col1 from table2
等值连接不就行了,select 出要出现的表中的字段。select * from table1 union select * from table2 into newtable (两个table字段兼容)
t1 a b 1 123 2 132t2 a c 1 323 2 333select t1.a,t1.b,t2.c from t1,t2 where t1.a=t2.a 显示2个表 a关联只显示一次
1>"二表关联,然后合并相同字段的那一列":这个用连接 比如:表1(id)和表2(tid)相同. select a.*,b.* from 表1 a join on 表2 b on 表1.id=表2.tid [where.....]2>两个表的查询结果生成一个表:可以用UNION(不过,前提是这N个表的结构类型都相同) 比如:表1和表2的结构相同. select * from 表1 union select * from 表2 .....
支持楼上sun30(勇敢飞翔) ( ) 信誉:100 1>"二表关联,然后合并相同字段的那一列":这个用连接 比如:表1(id)和表2(tid)相同. select a.*,b.* from 表1 a join on 表2 b on 表1.id=表2.tid [where.....]2>两个表的查询结果生成一个表:可以用UNION(不过,前提是这N个表的结构类型都相同) 比如:表1和表2的结构相同. select * from 表1 union select * from 表2 .....
select A.id, A.名字 + B.名字 as 新名字 from A inner join B on A.id=B.id
select ... into newtable
from old1,old2
where ...
select ...,old1.col1+old2.col1 as col1
from old1,old2
where ...
where A.a =B.a and A.b=B.b
楼主的意思是,字段关联的,且相等的,只取其中一个表的,不知我理解可对。
要生成一个新表:
select A.a,A.b,A.other,B.other into #t from A,B
where A.a =B.a and A.b=B.b
独特的双数据源连接,全功能的表格组件!http://www.anylib.com
UNION ALL
select col1 from table2
union select * from table2
into newtable
(两个table字段兼容)
a b 1 123
2 132t2
a c
1 323
2 333select t1.a,t1.b,t2.c from t1,t2 where t1.a=t2.a 显示2个表 a关联只显示一次
比如:表1(id)和表2(tid)相同.
select a.*,b.* from 表1 a join on 表2 b on 表1.id=表2.tid [where.....]2>两个表的查询结果生成一个表:可以用UNION(不过,前提是这N个表的结构类型都相同)
比如:表1和表2的结构相同.
select * from 表1
union
select * from 表2
.....
1>"二表关联,然后合并相同字段的那一列":这个用连接
比如:表1(id)和表2(tid)相同.
select a.*,b.* from 表1 a join on 表2 b on 表1.id=表2.tid [where.....]2>两个表的查询结果生成一个表:可以用UNION(不过,前提是这N个表的结构类型都相同)
比如:表1和表2的结构相同.
select * from 表1
union
select * from 表2
.....
select
A.id,
A.名字 + B.名字 as 新名字
from A
inner join B on A.id=B.id