Rick
Rick

Reputation: 2308

MySQL: Search range of strings with slash

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

Upvotes: 0

Views: 2194

Answers (1)

Richard
Richard

Reputation: 850

What about using the substring_index function?

select substring_index(fieldname,'/',-1) as v from tablename where v between 1 and 5

Upvotes: 1

Related Questions