refiking Posted April 9, 2010 Share Posted April 9, 2010 I am trying to display all the records that begin with A - M only. Here is the basic query: mysql_query("select stores_title, stores_id from stores"); Quote Link to comment https://forums.phpfreaks.com/topic/198078-only-return-records-by-their-alphabetical-range/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 9, 2010 Share Posted April 9, 2010 select stores_title, stores_id from stores WHERE stores_title REGEXP '^[a-m]' ORDER BY stores_title Quote Link to comment https://forums.phpfreaks.com/topic/198078-only-return-records-by-their-alphabetical-range/#findComment-1039328 Share on other sites More sharing options...
JustLikeIcarus Posted April 9, 2010 Share Posted April 9, 2010 Same as the one above just modified so that case isn't an issue. select stores_title, stores_id from stores WHERE lower(stores_title) REGEXP '^[a-m]' ORDER BY stores_title Quote Link to comment https://forums.phpfreaks.com/topic/198078-only-return-records-by-their-alphabetical-range/#findComment-1039556 Share on other sites More sharing options...
PFMaBiSmAd Posted April 9, 2010 Share Posted April 9, 2010 REGEXP is not case sensitive, except when used with binary strings. Quote Link to comment https://forums.phpfreaks.com/topic/198078-only-return-records-by-their-alphabetical-range/#findComment-1039574 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.