Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
| Search | Today's Posts | Mark Forums Read
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 9th, 2008, 01:52 PM
Authorized User
 
Join Date: Jun 2004
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Selecting emails by domain (TLD) from MySQL table?

Hi,

I have a table with a large number of emails (10000+). I need to extract specific emails based on their domain extension (TLD). For example I want to extract any .uk domains only from the table. How can I do this

Your help would be much appreciated.
  #2 (permalink)  
Old January 10th, 2008, 12:42 AM
Friend of Wrox
 
Join Date: Oct 2007
Location: , , .
Posts: 130
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via AIM to urtrivedi
Default


SELECT * where REVERSE(LEFT(REVERSE(email),LOCATE('.',REVERSE(ema il)) - 1)) ='uk' FROM table

above query will give you list of emails ending with .uk

Also refer to
http://dev.mysql.com/doc/refman/5.0/...-functions.htm

urt
  #3 (permalink)  
Old January 11th, 2008, 04:32 PM
Authorized User
 
Join Date: Jun 2004
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by urtrivedi


SELECT * where REVERSE(LEFT(REVERSE(email),LOCATE('.',REVERSE(ema il)) - 1)) ='uk' FROM table

above query will give you list of emails ending with .uk

Also refer to
http://dev.mysql.com/doc/refman/5.0/...-functions.htm

urt
Hi urt,

I tried your query changing the table name, but it seems to throw an error?
I am running it on MySql 4.1 in MySQLadmin.

Code:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where REVERSE( LEFT( REVERSE( email ) , LOCATE( '.' , REVERSE( email ) ) - 1 ) )' at line 1
Please advise

Ian



Similar Threads
Thread Thread Starter Forum Replies Last Post
send emails with an Excel table as text format peterlihh Excel VBA 4 October 29th, 2008 04:04 PM
Selecting Data from a table nkrust Javascript 7 January 11th, 2007 05:44 AM
sending emails for all users in the domain arabuafef ASP.NET 1.0 and 1.1 Basics 6 December 6th, 2006 10:51 AM
PhP - MySql Connect From Another Domain mani_he Pro PHP 13 December 21st, 2004 01:03 PM
Selecting and Making a table gmoney060 Classic ASP Databases 4 August 19th, 2004 10:06 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.