Hi All;
I have been working on trying to create a query to search on a range of 'numbers' from the database. Actually, if the search was just numbers, I'd be OK. Here's where I run into the problem...
I have a table set up with approximately 5000 entries. The first three fields in the table are as follows:
id range_start range_end
1 0A00 9A99
2 0B00 9B99
3 AA00 ZZ99
4 123A501 123A699
Now... what I want to do is to be able to enter a string to search for, such as 1A46. This number fits the range of id#1 (0A00-9A99) but I have not been able to figure out a way to search the DB for this.
I even tried using the hexdec function to convert the range start and end to decimal. Problem with that is that the first range (0A00-9A99) returns 2560-39577 and the seach string returns 6726 which fits the range. However, id#2 (0B00-9B99) returns 2816-39833, which the search string (1A46 or 6726 Dec) also fits... but it shouldn't due to the range being a 'B' range and I am searching on 'A'.
Now I could search for strings containing an 'A' first, but that wouldn't work for id#3 as the range is not static, like id#1 or id#2... for example, I want to find which range fits the string 'AV55'. The range must first be calculated... AA00, AA01, AA02... AA99, AB00... AV55... FG00... ZZ98, ZZ99. ('...' are gaps in the range, for example only).
My other predicament is that the ranges are not a consitant length. For example, id#1 and #2 are 4 characters, id#4 is 7 characters. Some ranges also vary within the range... range A01 thru A100 (3 characters thru 4 characters).
I'll end this now before I babble on way too much! Any help would be greatly appreciated!
Kyle Stubbins
kyle@mySAFETECH.com