Re: [PHP] Selecting between using letters

2003-12-29 Thread Lowell Allen
 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



RE: [PHP] Selecting between using letters

2003-12-29 Thread Vail, Warren
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:[EMAIL PROTECTED]
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Selecting between using letters

2003-12-29 Thread Doug Parker
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.




http://www.phreshdesign.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Selecting between using letters

2003-12-29 Thread Vail, Warren
How about the following;

SELECT DISTINCT left( name, 1 ) AS idx, count( * ) 
FROM users
GROUP BY idx 

produces a count of the names found for each letter, then you can make
decisions about your range of letters, like a max of 250 between letters, or
some such number.

Warren Vail

-Original Message-
From: Doug Parker [mailto:[EMAIL PROTECTED]
Sent: Monday, December 29, 2003 2:18 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [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.




http://www.phreshdesign.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Selecting between using letters

2003-12-29 Thread Thorsten Schmidt
Doug Parker wrote:

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.




http://www.phreshdesign.com
 

SELECT  * FROM  `user` WHERE lastname   'A' AND lastname   'E'

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php