如何like在SQL中的数字列上进行搜索?
我想要数字like '0.0000%'.  
我试过了
select * from emp where emp_id & '' like '123%'
select * from emp where CONVERT(varchar(20), emp_id) like '123%'
Run Code Online (Sandbox Code Playgroud)
但是徒劳无功
请帮我
无论您使用哪种DBMS并假设您有充分的理由这样做,您有几种方法可以解决这些问题.我现在可以想到三个:
将数字转换为字符串并使用LIKE运算符:
select *
from emp
where to_char(emp_id) like '123%';
Run Code Online (Sandbox Code Playgroud)直接使用数学运算符(如Andrey所建议的),例如:
select *
from table
where num between 0 and 0.0001;
Run Code Online (Sandbox Code Playgroud)构造一个数学表达式(实际上,这只是方法2的另一种情况),例如:
select *
from table
where abs(num - round(num, 5)) < 0.00001;
Run Code Online (Sandbox Code Playgroud)使用比较运算符(> 和 <):
select * from table where num > 0 and num < 0.00001
Run Code Online (Sandbox Code Playgroud)