I have a SQL Server 2008 R2 database with a table called productmanufacturers, with columns of ID, Name. I want to get all records where the Name column begins with a number.

I have tried the following, but it is messy and I am thinking too cumbersome. Is there a more reduced way of writing the query?

Current Query:

select * from productmanufacturers where Name like '0%' or Name like '1%' or Name like '2%' or Name like '3%' or Name like '4%' or Name like '5%' or Name like '6%' or Name like '7%' or Name like '8%' or Name like '9%'
有帮助吗?

解决方案

try this !

select * from productmanufacturers where Name like '[0-9]%'

DEMO

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top