小编典典

将String转换为int并在Where子句中使用

sql

如何转换字符串字段并用于Where子句。

select * from student 
where (cast (nvl(linerevnum,'0') as int)) = 1

衬板是varchar2

例外:无效的数字


阅读 241

收藏
2021-04-07

共1个答案

小编典典

仅在数字时比较

select * from student 
where 
  (
  case when ISNUMERIC( linerevnum ) 
  then cast (linerevnum as int)
  else null
  end  ) = 1

或简单:

select * from student 
linerevnum = '1'
2021-04-07