SQL-varchar列上的WHERE-between
我有一个表公司,列customerID,我希望每个客户id从80000到80999 但是customerID列是varchar,其中一些包含字母 因此,我必须将customerID放入“”中,当我尝试此查询时:SQL-varchar列上的WHERE-between,sql,where,between,Sql,Where,Between,我有一个表公司,列customerID,我希望每个客户id从80000到80999 但是customerID列是varchar,其中一些包含字母 因此,我必须将customerID放入“”中,当我尝试此查询时: select * from company where customerID between '80000' and '80999' 例如,它还返回customerID 800 你知道如何解决这个问题吗?你可以用正则表达式格式化。类似这样的内容应该让您开始如果CustomerID是一个
select *
from company
where customerID between '80000' and '80999'
例如,它还返回customerID 800
你知道如何解决这个问题吗?你可以用正则表达式格式化。类似这样的内容应该让您开始如果CustomerID是一个整数,它应该是一个整数,那么您不需要在numbers周围加引号。它应该解决这个问题:
select *
from company
where customerID between 80000 and 80999;
谢谢-有趣的解决方案,在我的例子中,函数是LENcustomerID=5
select *
from company
where customerID between 80000 and 80999;