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
Post a Comment