易截截图软件、单文件、免安装、纯绿色、仅160KB

求SQL,table1去重插入table2

有table1(num,a,b,c)
有table2(num,a,b,c)
把table2中所有字段插入table1中,但要去掉table2中num字段重复记录.

insert into table1(num,a,b,c)select distinct(num),a,b,c from table2 where num <>'NULL'
我这样没有去掉重复记录,请高手帮忙
试试
SQL code:
insert into table1(num,a,b,c)select distinct num,a,b,c from table2 where num is not NULL



insert into table1(num,a,b,c)select distinct(num),a,b,c from table2 where num <>'NULL'
你这样要完全重复才能去掉
而且你的NULL?
NUM是字符型吗?
如果不是应该要用NUM IN NOT NULL

只要num字段是完全一样的,我就去重,a,b,c字段不管它.num是字符型

引用
只要num字段是完全一样的,我就去重,a,b,c字段不管它.num是字符型

那你A,B,C想保留什么?

num,去重后,保留的那一条记录的num,a,b,c字段数据原样插入table1中

引用
试试
SQL codeinsertinto table1(num,a,b,c)selectdistinct num,a,b,cfrom table2where numisnotNULL


这样不得行.还是没有去重,你这样是要整条数据都相同才能去重

引用
num,去重后,保留的那一条记录的num,a,b,c字段数据原样插入table1中

那你想保留哪一条呀,随便吗?
insert into table1(num,a,b,c)select num,a,b,c from


相关问答:

门外汉求助...关于后台+SQL+ASP

....接到一个小程序..工作原来大概是这样的...前台是WEB服务器.架构就是ASP+SQL..前台由ASP向SQL添加服务类别(表单).然后又后台程序读取表单..要实时读取..然后显示在服务器上面..从理论上面能行通不?如果可以..后台 ......

sql server 存储过程循环赋值的问题

小弟是个新手 现在有个问题一直不能解决
例如
procedure produce_proc
    @p001 nvarchar(8000),
    @p002 nvarchar(8000),
    @p003 nvarchar(8000),
  & ......

总会碰到怪的问题,sql问题

sql2005
select *from v_ddxx where d_sfsc='0' and (g_ssbm='1001' or g_ssbm='1002') and (xxf>0 and  xxfwzf <>0 ),执行速度慢的要死,但是如果把(xxf>0 and  ......

sql 查询

  我有一个月和日组成的数字,有两组月和日
想在身份证号中挑选出在该该两组月日之间出生的人,不知道应该怎么写.
身份证号有可能是15位或者18位

月日组合的形式如下
10-17/04-20
月-日/月- ......

sql 问题

DateTime startTime=DateTime(em_1.Text)
DateTime endTime=DateTime(em_2.Text)

string sql
sql = dw_1.GetSQLSelect()+"Where (StartTime> '"+startTime+"') and (EndTime ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号