现在我有两张表ypdebt和spdebt字段如下
表1.A字段 表2.A字段
101 101
102 105
104 106
我现在要得到一个新表
新表.A字段
101
102
104
105
106
就是要两个表的A字段相加然后取唯一,请问SQL语句怎么写?请各位大侠指教啊?
表1.A字段 表2.A字段
101 101
102 105
104 106
我现在要得到一个新表
新表.A字段
101
102
104
105
106
就是要两个表的A字段相加然后取唯一,请问SQL语句怎么写?请各位大侠指教啊?
解决方案 »
- 同一种功能,在程序里实现好,还是在数据库里实现好?
- 有点麻烦了。 硬盘坏了,用文件恢复工具只恢复了一个备份文件,恢复不了。
- SQL 2000 添加的最后一条数据在最后一行接着问
- 如何改变SQLSERVER的默认日期格式
- 如何将xp_cmdshell列出的目录内容写入文本或数据库列表中
- 急求一条SQL语句,有难度,数据量很大,希望能有好的方法!谢谢!
- 关于dbo用户登录名空不空的怪问题
- 求SQL语句
- 求sql server 下载地址
- 任务管理(分不够在加)
- 请问怎样修改已经存在的datetime类型的值?比如:有一个datetime类型的值是2007-1-9 21:26:44,要把2007该为2008
- 怎么将数据前面的0都截掉呢?
union
select a from table2
union
select a from 表2
union
select A from tb2
union
select a from B where exists not (select*from B where A.a=B.a)
union
select 字段 from 表2
select A from ypdebt
union
select a from spdebt
select A from ypdebt
union
select a from spdebt
select a字段 from 表1
union
select a字段 from 表2方法2:
inset into 表1 select * from 表2 not exists(select * from 表1 where 表1.a字段=表2.a字段)
select * from 表1你也可以用临时表或变量表抢个沙发先