这个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添加服务类别(表单).然后又后台程序读取表单..要实时读取..然后显示在服务器上面..从理论上面能行通不?如果可以..后台 ......
小弟是个新手 现在有个问题一直不能解决
例如
procedure produce_proc
@p001 nvarchar(8000),
@p002 nvarchar(8000),
@p003 nvarchar(8000),
& ......
PB中开发的。
DateTime startTime=DateTime(em_1.Text)
DateTime endTime=DateTime(em_2.Text)
string sql
sql = dw_1.GetSQLSelect()+"Where (StartTime> '"+startTime+&q ......
我有一个月和日组成的数字,有两组月和日
想在身份证号中挑选出在该该两组月日之间出生的人,不知道应该怎么写.
身份证号有可能是15位或者18位
月日组合的形式如下
10-17/04-20
月-日/月- ......