Php MySQL:介于10万和20万之间

Php MySQL:介于10万和20万之间,php,mysql,sql,laravel,laravel-4,Php,Mysql,Sql,Laravel,Laravel 4,我正在试图找出最好的方法来执行介于之间的查询,但是能够从单元格中取出一个字母。。。该列由序列号组成,如V123456,显然BETWEEN与字母不匹配 有没有一种方法可以让我基本上忽略序列的第一个字符,然后在此基础上运行我的BETWEEN语句 Get me all records between V100000 and V100050 试试这个: select * from records_table where serial >= "V100000" and serial <= "

我正在试图找出最好的方法来执行
介于
之间的查询,但是能够从单元格中取出一个字母。。。该列由序列号组成,如
V123456
,显然
BETWEEN
与字母不匹配

有没有一种方法可以让我基本上忽略序列的第一个字符,然后在此基础上运行我的
BETWEEN
语句

Get me all records between V100000 and V100050
试试这个:

select * from records_table where serial >= "V100000" and serial <= "V150000"
从记录表中选择*,其中serial>=“V100000”和serial
试试看,如果不行,请告诉我

所以对你来说:

SELECT * FROM table WHERE serial BETWEEN 'V123456' AND 'V123466'

只要你信的开头是一样的,这就行了。这在我的本地服务器上起到了测试作用。我有Col1作为ID,Col2作为序列号。我插入了7个变量(V10000-V10007)并运行了一个脚本来获取V10002和V10005之间的所有序列,它成功了。

我进行了以下测试:

create table test(

 searchfield varchar(100)

);

insert into test values('V100');
insert into test values('V101');
insert into test values('V102');
insert into test values('V103');
insert into test values('V104');
insert into test values('V105');
insert into test values('V106');
insert into test values('V107');
insert into test values('V108');
insert into test values('V109');
insert into test values('V110');
测试查询:

select * from test t 
where substring(t.searchfield,2) between 103 and 105;

Sqlfiddle here:

数据库存储区中的记录是作为数字还是也包括V?这个问题仍然存在吗?你的问题解决了吗?
select * from test t 
where substring(t.searchfield,2) between 103 and 105;