On Fri, Jul 31, 2009 at 5:55 PM, Phpster<phpster@xxxxxxxxx> wrote: > What about > > $sql = "SELECT DISTINCT ID, name, address FROM restaurants WHERE > left(name, 1) between 0 and 9"; > > > > > Bastien > > Sent from my iPod You need to wrap the 0 and the 9 in single quotes, or else it returns everything. $sql = "SELECT DISTINCT ID, name, address FROM restaurants WHERE left(name, 1) between '0' and '9'"; Performance could be an issue, also. I tried this and the two versions I posted on her other thread against a table I have that has just over 8700 rows in it. This version took over 9 times longer to execute. (Granted, on a table that small it's still 0.0092 seconds compared to 0.0010 seconds. Either of those times is acceptable in my book, but on a larger table a 9x performance drain could be a serious issue.) That's because the engine has to examine every row in the table and calculate left(name, 1) before it can compare that value to the range. The other versions I posted can simply scan/seek the index within a range. Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php