I have a query to filter the result in mysql database into given letter ranges: I want to display the items who starts with letter a-f. I uses this query but I think there is a better query to do that.
SELECT DISTINCT title FROM tables WHERE LEFT(title, 1) ='a' AND LEFT(title, 1)='b' ..... AND LEFT(title, 1)='f';
You can use regex something like
It’s case insensitive. But you might want to remove
DISTINCTif you do not want single result for uppercase and lowercase word. For example,Edit#1 updated case for upper-case, lower case query and example for without distinct
However you can force case sensitivity using
binarykey word likeEdit:2 case sensitive search added