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"); 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 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 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 Quote REGEXP is not case sensitive, except when used with binary strings. 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
Archived
This topic is now archived and is closed to further replies.