glennn.php Posted July 30, 2008 Share Posted July 30, 2008 hi all - having this: mysql_query("SELECT * FROM menu ORDER BY cat ASC"), i'm trying to retrieve records where 'cat' starts with anything from A to M. can anyone help a chap out? Thanks much, GN Quote Link to comment Share on other sites More sharing options...
beebum Posted July 30, 2008 Share Posted July 30, 2008 mysql_query("SELECT * FROM menu WHERE SUBSTRING(cat,1,1) between 'a' and 'm' ORDER BY cat ASC") Quote Link to comment Share on other sites More sharing options...
glennn.php Posted July 30, 2008 Author Share Posted July 30, 2008 awesome, thanks i found another tute that did ...REGEXP 'A%-M%' order by cat ASC... which worked as well; is there a reaon one is better than the other? PHP version, mysql version, etc...? Thanks for your help. GN Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted July 30, 2008 Share Posted July 30, 2008 Both beebum's and the query you posted are using mysql functions. Quote Link to comment Share on other sites More sharing options...
beebum Posted July 30, 2008 Share Posted July 30, 2008 I suspect that the regex would be faster. Just run each one from the command line to see. Quote Link to comment Share on other sites More sharing options...
glennn.php Posted July 30, 2008 Author Share Posted July 30, 2008 thanks both of you!!! Quote Link to comment 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.