Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Extracting data based on email id

Author  Topic 

kishore7
Starting Member

13 Posts

Posted - 2012-08-06 : 16:26:14
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

1974 Posts

Posted - 2012-08-06 : 16:33:32
SELECT email
FROM Table
WHERE email LIKE '%gmail.com'

-Chad
Go to Top of Page

kishore7
Starting Member

13 Posts

Posted - 2012-08-06 : 16:38:07
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

1974 Posts

Posted - 2012-08-06 : 16:41:45
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

277 Posts

Posted - 2012-08-07 : 09:24:06
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
   

- Advertisement -