Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQL-varchar列上的WHERE-between_Sql_Where_Between - Fatal编程技术网

SQL-varchar列上的WHERE-between

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是一个

我有一个表公司,列customerID,我希望每个客户id从80000到80999

但是customerID列是varchar,其中一些包含字母

因此,我必须将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;