如何在带有数字字段的SQL中使用LIKE条件? [英] How to use LIKE condition in SQL with numeric field?
问题描述
我正在使用此查询来获取一些特定数据:从emp中选择*,其中emp_name喜欢's%'";
I'm using this query to get some specific data: "select * from emp where emp_name LIKE 's%'";
emp_nam是字符字段,如何与数字字段使用相同的逻辑条件?像这样:
emp_nam is character field, how can I use the same logic condition with numeric field? something like:
从emp中选择*,其中emp_id ????
"select * from emp where emp_id ????
其中emp_id是数字字段.
where emp_id is numeric field.
谢谢
推荐答案
在Access中,您可以将数字字段与空字符串连接起来,以将其强制转换为可以使用LIKE进行比较的字符串:
In Access you can concatenate the numeric field with an empty string to coerce it into a string that you can compare using LIKE:
select * from emp where emp_id & '' like '123*'
还请注意,Access使用*而不是%作为通配符.请参阅:类似运算符(Microsoft Access SQL).
Also note that Access uses * not % as the wildcard character. See: Like Operator (Microsoft Access SQL).
这篇关于如何在带有数字字段的SQL中使用LIKE条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!