Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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.
Reply With Quote
  #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
Reply With Quote
  #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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:04 PM.


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