views:

37

answers:

1

I have a varchar field with the following data:

Interface
Gig1/0/1
Gig1/0/3
Gig1/0/5
Gig1/0/10
Gig1/1/11

I am trying to do a search (BETWEEN).

Select * from test1 where Interface Between "Gig1/0/1" and "Gig1/0/5"  

Returns all the records except for Gig1/1/11

+1  A: 

What about using the substring_index function?

select substring_index(fieldname,'/',-1) as v from tablename where v between 1 and 5
Richard
That works: select interface from test1 where substring_index(interface,'/',-1) between 1 and 5, but only if I am searching for the last numbers before the right most slash. Can't search for Gig1/1/11.
Rick
...assuming I had more records like Gig1/1/10, Gig1/1/5... How would I search for those?
Rick
perhaps using "select substring_index(fieldname,'/',-2) as v from tablename where v between '0/1' and '1/5'" as this would select 1/10,1/15 etc.
Richard