database - Mysql reverse pattern matching - alternative? -


lets have following values in mysql database table:

a ab abc abcd 

i looking fast way retrieve values prefix of input. works:

select * table 'abcde12345' concat(col, '%'); 

...but slow on large datasets. there smarter ways of storing data enable fast lookups?

this might help, along index(col):

select  *      table      col between 'a' , 'abcde12345'       ,  'abcde12345' concat(col, '%'); 

this more likely:

select *      table     col in ('a', 'ab', 'abc', ..., 'abcde12345'); 

the latter version could constructed code 'abcde12345', or (more painfully) in stored procedure.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -