Emily
Emily

Reputation: 1

SQL Query to pull rows starting with a certain 3 digits

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?

Upvotes: 0

Views: 1602

Answers (1)

Lukas Florea
Lukas Florea

Reputation: 126

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

Upvotes: 1

Related Questions