select A.類型 ,A.厚度 ,B.實際類型
from A表 A
left join B表 B on B.類型=A.類型
from A表 A
left join B表 B on B.類型=A.類型
解决方案 »
- 安装SQL2000个人版的问题
- 邹建大哥,刚才那个取前面几个字节的问题有点奇怪的现象,请帮帮我!
- MSSQL如果表中数据大于2000万条,那要用什么方法查
- MSSQL 在legato 环境中 Failover 后, Replicate 不工作
- 在线求left join的用法,谢谢
- 小问题,有关数据库数据备份问题
- 请教,要锁住一个表,在程序里怎么实现,谢谢,用的sql_server 6.0
- 当同时插入多条记录时,触发器的动作是怎样的?
- 从SQLSERVER7.0升级到 SQL2000 的问题
- sql2005的复制表问题
- 请问在sqlserver里,这样的语句怎么写
- 在win2000+sp4环境下安装SQL2000出错,求救!
create table A表(類型 varchar(10),厚度 decimal(5,1))
insert A表 select '4H',1.1
union all select '4G',1.5create table B表(類型 varchar(10),標准厚度 decimal(5,1),最小厚度 decimal(5,1),比較符1 varchar(10),最大厚度 decimal(5,1),比較符2 varchar(10),實際類型 varchar(10))
insert B表 select '4H',1.0,0.6,'>=',1.3,'<=','4H1'
union all select '4G',1.2,1.0,'>' ,1.8,'<' ,'4G2'
goselect a.*,b.實際類型
from A表 a,B表 b
where a.類型=b.類型
and
case b.比較符1
when '<' then case when a.厚度< b.最小厚度 then 1 else 0 end
when '<=' then case when a.厚度<=b.最小厚度 then 1 else 0 end
when '=' then case when a.厚度= b.最小厚度 then 1 else 0 end
when '>' then case when a.厚度> b.最小厚度 then 1 else 0 end
when '>=' then case when a.厚度>=b.最小厚度 then 1 else 0 end
end=1
and
case b.比較符2
when '<' then case when a.厚度< b.最大厚度 then 1 else 0 end
when '<=' then case when a.厚度<=b.最大厚度 then 1 else 0 end
when '=' then case when a.厚度= b.最大厚度 then 1 else 0 end
when '>' then case when a.厚度> b.最大厚度 then 1 else 0 end
when '>=' then case when a.厚度>=b.最大厚度 then 1 else 0 end
end=1
go--删除测试
drop table A表,B表/*--测试结果類型 厚度 實際類型
---------- ------- ----------
4H 1.1 4H1
4G 1.5 4G2(所影响的行数为 2 行)
--*/