如何转换字符串字段并用于Where子句。这样的异常请帮助找到错误的东西。
select * from student
where (cast (nvl(linerevnum,'0') as int)) = 1
linerevnum是varchar2
例外: 无效的号码
答案 0 :(得分:6)
仅在数字时比较
select * from student
where
(
case when ISNUMERIC( linerevnum )
then cast (linerevnum as int)
else null
end ) = 1
或简单:
select * from student
linerevnum = '1'