select * from ( select id,name from a表 union all select id,name from b表 union all select id,name from c表)d
select id,name into D from a表 union select id,name from b表 union select id,name from c表union和union all的区别是一个过滤重复记录一个不过滤重复记录
--查詢3張表的所有記錄,則用 select * from ( select id,name from a表 union all select id,name from b表 union all select id,name from c表)d--查詢3張表中沒有重復的記錄,則用 select * from ( select id,name from a表 union select id,name from b表 union select id,name from c表)d--union all 比 union 的效率高
三张表的字段格式都一模一样 怎么合并成一张表 如 a表 b表 c表 d表 id name id name id name ?= id,nameselect * into d from ( select * from a union all select * from b union all select * from c ) t
select id,name from a表
union all
select id,name from b表
union all
select id,name from c表)d
select id,name into D from a表
union
select id,name from b表
union
select id,name from c表union和union all的区别是一个过滤重复记录一个不过滤重复记录
select * from (
select id,name from a表
union all
select id,name from b表
union all
select id,name from c表)d--查詢3張表中沒有重復的記錄,則用
select * from (
select id,name from a表
union
select id,name from b表
union
select id,name from c表)d--union all 比 union 的效率高
如
a表 b表 c表 d表
id name id name id name ?= id,nameselect * into d from
(
select * from a
union all
select * from b
union all
select * from c
) t
union all
union --会合并相同项
union --会合并相同项
union all
union --会合并相同项