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 = '南')
------解决方案--------------------
这样更明白些,容易理解。
SQL code
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
*/