I'm not exactly sure if this is the right syntax. I can see that maybe a couple of domains would get cut out of this if there spelt almost the same. What you need to find out is the char count of the smallest domain name. Then replace smallestdomain with that number. What the rest of the select statement does is only get the last so many chars up to the smallest domain name and then the distinct will only return those that are not the same. I'm sure you can work around with this and find something that will do exactly what you want.
SELECT DISTINCT email, substring(email,LENGTH(email)-smallestdomain, smallestdomain) as domain from tbl_emails; Matthew Scarrow ComIT Solutions Inc. www.comit.ca Phone: 519-442-0100 Fax: 519-442-0429 -----Original Message----- From: Kirk Babb [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 10, 2002 10:20 PM To: [EMAIL PROTECTED] Subject: Re: help with MySQL SELECT statement wait, how will the MySQL SELECT DISTINCT pick only one between these two addresses (as an example): [EMAIL PROTECTED] [EMAIL PROTECTED] I only need one email address each for alltel.com, one for ualr.edu, one for target.com, etc. when there might be 50 email addresses from each of those domains. I intend to then parse the adresses leaving only a list of "whatever.com"s which I will stick into an array for my validation function to use. Or am I making a mountain out of a molehill here? TIA -Kirk --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php