0

I have a table company with column customerID and I want every customer id from 80000 to 80999.

But the column customerID is varchar an some of them contain letters.

So, I must put customerID into ' ' and when I try this query:

select *
from company
where customerID between '80000' and '80999'

it returns also customerID 800 for example.

Any ideas how this issue can be solved?

user1673665
  • 516
  • 3
  • 8
  • 21

3 Answers3

0

You could use regular expressions to format. Something like this should get you started Query to get only numbers from a string

Community
  • 1
  • 1
Daven.Geno
  • 21
  • 4
0
where customerID between '80000' and '80999'
  and character_length(customerID) = 5 -- only five digit IDs
dnoeth
  • 59,503
  • 4
  • 39
  • 56
0

If the CustomerID is an integer, which it should, you don't need the quotes around the numnbers. It should solve the problem:

select *
from company
where customerID between 80000 and 80999;
3nrique0
  • 349
  • 6
  • 14