select * from tb where 15 between left(字段,LOCATE('-',字段)-1)+0 and SUBSTRING(字段,LOCATE('-',字段)+1,LENGTH(字段)-LOCATE('-',字段))+0;
select col from yourTable where col<='15' order by col desc limit 1;
create table tb(col varchar(100)); insert tb select '10-12' union all select '13-18' union all select '19-28' union all select '29-30' select * from tb where 15 between left(col,LOCATE('-',col)-1)+0 and SUBSTRING(col,LOCATE('-',col)+1,LENGTH(col)-LOCATE('-',col))+0;/**结果col 13-18 **/
select * from tt3 where mid(gg,1,instr(gg,'-')-1)<'15' and mid(gg,instr(gg,'-')+1)>'15'orselect * from tt3 where 0+mid(gg,1,instr(gg,'-')-1)<15 and 0+mid(gg,instr(gg,'-')+1)>15
*
from
tb
where
15
between
left(字段,LOCATE('-',字段)-1)+0
and
SUBSTRING(字段,LOCATE('-',字段)+1,LENGTH(字段)-LOCATE('-',字段))+0;
from yourTable
where col<='15'
order by col desc
limit 1;
insert tb
select '10-12' union all
select '13-18' union all
select '19-28' union all
select '29-30' select
*
from
tb
where
15
between
left(col,LOCATE('-',col)-1)+0
and
SUBSTRING(col,LOCATE('-',col)+1,LENGTH(col)-LOCATE('-',col))+0;/**结果col
13-18 **/
mid(gg,1,instr(gg,'-')-1)<'15'
and
mid(gg,instr(gg,'-')+1)>'15'orselect * from tt3 where
0+mid(gg,1,instr(gg,'-')-1)<15
and
0+mid(gg,instr(gg,'-')+1)>15