I have a phone number table storing the phone number as varchar (20). I have a requirement to implement a search for integers, and only in the last part of the number, so a typical query would be:
SELECT * FROM PhoneNumbers WHERE Number LIKE '%1234'
How can I put an index in a column Numberto make these searches effective? Is there a way to create an index that sorts records on an inverted row? Another option may be to change the numbers before storing them, which will give queries such as:
SELECT * FROM PhoneNumbers WHERE ReverseNumber LIKE '4321%'
However, this will require that all database users always change the row. This can be solved by saving both the normal and the inverse number, and updating the number updated by the trigger when inserting / updating. But this solution is not very elegant.
Any other suggestions?
source
share