SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Extracting data based on email id
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kishore7
Starting Member

13 Posts

Posted - 08/06/2012 :  16:26:14  Show Profile  Reply with Quote
Hi,

In my table i hav first_name and email id's
i need help in writing a query a, such that it fetches only records that has email id's that has domain name as gmail

for ex

abc@gmail.com (i want only records , with gmail)
xyz@yahoo.com(i dont want these records)

thanks in advance

chadmat
The Chadinator

USA
1961 Posts

Posted - 08/06/2012 :  16:33:32  Show Profile  Visit chadmat's Homepage  Reply with Quote
SELECT email
FROM Table
WHERE email LIKE '%gmail.com'

-Chad
Go to Top of Page

kishore7
Starting Member

13 Posts

Posted - 08/06/2012 :  16:38:07  Show Profile  Reply with Quote
Thanks for the reply,,

But how can i get all the records, without gmail in their email id's
Go to Top of Page

chadmat
The Chadinator

USA
1961 Posts

Posted - 08/06/2012 :  16:41:45  Show Profile  Visit chadmat's Homepage  Reply with Quote
I dislike answering questions like this because I am sure there is a better way to do whatever it is you are doing, but to answer the question, just use NOT LIKE in the same query.

-Chad
Go to Top of Page

xhostx
Constraint Violating Yak Guru

USA
261 Posts

Posted - 08/07/2012 :  09:24:06  Show Profile  Reply with Quote
this will do the work:
declare @e varchar(100)
set @e='abaaac.aaaaa001@gmail.com'
select SUBSTRING(@e, 1, CHARINDEX('@',@e)-1)

--------------------------
Joins are what RDBMS's do for a living
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000