这个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.[序列号]
相关问答:
....接到一个小程序..工作原来大概是这样的...前台是WEB服务器.架构就是ASP+SQL..前台由ASP向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 ......
我有一个月和日组成的数字,有两组月和日
想在身份证号中挑选出在该该两组月日之间出生的人,不知道应该怎么写.
身份证号有可能是15位或者18位
月日组合的形式如下
10-17/04-20
月-日/月- ......
在建立与服务器的连接时出错。在连接到 SQL Server 2005 时,在默认的设置下 SQL Server 不允许进行远程连接可能会导致此失败。 (provider: SQL 网络接口, error: 26 - 定位指定的服务器/实例时出错)
== ......
我看一个教程上看了一个语句,用于两个表联合查询的,但我不是很懂,请指教
select t.*,publisherName from titles t left outer join publishers p on t.publisherid=p.publisher
第一次接触,希 ......