27,580
社区成员
发帖
与我相关
我的任务
分享
declare @v varchar(10)
select @v = '40'
select * from (
select 1 id,'字符串比较40<5' sm,case when @v> '5' then @v else 5 end as v union
select 2,'数字比较40>5' ,case when @v> 5 then @v else 5 end union
select 3,'字符串比较40>300' ,case when @v>'300' then @v else 300 end union
select 4,'数字比较40 <300' ,case when @v> 300 then @v else 300 end
) a order by id
/*
id sm v
----------- ---------------- -----------
1 字符串比较40<5 5
2 数字比较40>5 40
3 字符串比较40>300 40
4 数字比较40 <300 300
*/
declare @v varchar(10)
select @v = '40'
select case when @v>5 then @v else 5 end
union select case when @v> 300 then @v else 300 end
/*
-----------
40
300
*/
select * from tb_register a where
exists (select 1 from tb_content where a.rid = rid
and pname ='面积' and ptype >=100)--sql会自动类型转换。
and
exists (select 1 from tb_content where a.rid = rid
and pname ='朝向' and ptype = '南')
select * from tb_register a where
exists (select 1 from tb_content where a.rid = rid
and (pname ='面积' and ptype >=100)--sql会自动类型转换。
and (pname ='朝向' and ptype = '南'))