How to use LIKE condition in SQL with numeric field? How to use LIKE condition in SQL with numeric field? sql sql

How to use LIKE condition in SQL with numeric field?


You can't do a wildcard on a number, however, if you really need to, you can convert the number to a varchar and then perform the wildcard match.

eg.

SELECT * FROM emp WHERE CONVERT(varchar(20), emp_id) LIKE '1%'


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*'

Also note that Access uses * not % as the wildcard character. See: Like Operator (Microsoft Access SQL).


No, you can't use LIKE for numeric fields.Try using <,> or =, >=, <= ;)

If you want to search in a numeric field for things like "beginning with 12" or sth like this, your design not fits your needs.