RE: [PHP] Selecting between using letters

From: Date: Mon, 29 Dec 2003 22:43:11 +0000
Subject: RE: [PHP] Selecting between using letters
Groups: php.general 
Request: Send a blank email to php-general+get-173454@lists.php.net to get a copy of this message
If the database is really large, some databases will attempt to use an index if you use "between" as in select * from table where lastname between "A" and "F" or > and < compares. not sure about MySQL, and notice I had to use the letter "F" to get all names beginning with "E" I seem to recall Sybase would use a table scan (read every row in the table) if an imbedded function was used in the where clause, and it would use an index with between. Haven't done any internals work with MySQL so not sure if this would speed things up or not. Warren Vail -----Original Message----- From: Lowell Allen [mailto:la@lowellallen.com] Sent: Monday, December 29, 2003 2:25 PM To: PHP Subject: Re: [PHP] Selecting between using letters > How would I create a select statement in MySQL that would return a range of > records from the LastName field where the value starts with a designated > letter - for example, returning the range where the first letter of LastName > is between A and E... > > Any help would be greatly appreciated. $sql = "SELECT * FROM table WHERE LastName REGEXP '^[A-E]'"; HTH -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#173454) next »