SQL Query to pull rows starting with a certain 3 digits

时间:2018-06-04 17:07:48

标签: sql-server-2017

I have a numbers column in my sql table and I want to pull all the numbers that start with 3 specific digits; how would I query this?

1 个答案:

答案 0 :(得分:1)

Use the "LIKE" query:

123 is the prefix. I think you have to store the numbers as strings though, just try it out on your data set :-)

 SELECT * from TableName Where ColumnName LIKE '123%'

See also this Q&A: In MySql, find strings with a given prefix