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

这个SQL语句这么写

SQL表一
序列号,    产品      bz

0001        mc      0

0002        mc      0

0003        mc1    0

SQL表二
序列号,    产品      bz


excl 表
序列号,    产品
0001      mc
0003      mc1 
0022      mc1


现在需要比对2表(以序列号和产品比对,对比对成功的让BZ改为1,不对的写入SQL表2)
 

 


需要比对的是,SQL表一
和excl 表


excl表是EXCL文件哟,比对成功的也要体现哟

SQL code:
if object_id('[t1]') is not null drop table [t1]
go
create table [t1]([序列号] varchar(4),[产品] varchar(3),[bz] int)
insert [t1]
select '0001','mc',0 union all
select '0002','mc',0 union all
select '0003','mc1',0
go
select * into t2 from t1 where 1=2;
go
if object_id('[excl]') is not null drop table [excl]
go
create table [excl]([序列号] varchar(4),[产品] varchar(3))
insert [excl]
select '0001','mc' union all
select '0003','mc1' union all
select '0022','mc1'

-->更新
update t1
set bz=1
where exists(select 1 from excl where t1.[序列号]=excl.[序列号]


相关问答:

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

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

一个简单的SQL语句

  我看一个教程上看了一个语句,用于两个表联合查询的,但我不是很懂,请指教
select t.*,publisherName from titles t left outer join publishers p on t.publisherid=p.publisher

第一次接触,希 ......

ado+sql创建表

各位大家好
VC+ado+sql创建表

我数据库里由一张TABLE表,现在我要一张TABLE1表。(注:我所建的TABLE1表通过对话框上的一编辑框输入,点击按钮后要建立TABLE1表,并且TABLE1表中的所有字段是从TABLE表中读 ......

PL/SQL问题

PL/SQL里面的TABLE---》QUERY界面

有SQL|OUTPUT|STATISTICS三个页面

为什么我在SQL里面用SELECT语句或者UPDATE后,OUTPUT和STATISTICS页面都没任何数据?

是要什么情况下,这2个页面也会有数据 ......

sqlite的sql语句问题

sqlite不会不支持and 吧?
select * from table where rootid=2 and uid=0 order by orderid asc,id asc
使用上面的语句查询不到数据,可是符合的条件是存在的.我取掉and,就有记录,不知道怎么回事
select * f ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号