Your best bet is to separate the prefix and the number out into distinct variables in your application language of choice, so instead of sending 66121 to the database you have the ability to send 66 and 121 as separate parameters.
With this in mind, the code you'll need will be something like this.
Assume that $prefix is 66 and $integer is 121 for the purposes of this query. If the user hasn't specified either they will be passed in as an empty string and the integer 0, respectively.
Code sql:
SELECT *
FROM tableName
WHERE prefix = '$prefix'
OR $integer BETWEEN startrange AND endrange;
Does this help?
Bookmarks