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
 PATINDEX

Author  Topic 

SharkAl
Starting Member

8 Posts

Posted - 2014-09-30 : 11:36:58
I want to search a table and display only results that contain particular Hotmail and yahoo email addresses. The code I am using currently is:

Select Name, Email, PATINDEX('%Hotmail%, Email) From tblPerson

How do I search for more than one email domain? Do I use a case statement, if so how?

Thanks in advance

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-09-30 : 11:49:25
Use the filter in a WHERE clause like this:
SELECT Name, EMail
FROM tblPerson
WHERE Email LIKE '%hotmail%' OR Email LIKE '%yahoo%'
Go to Top of Page

SharkAl
Starting Member

8 Posts

Posted - 2014-09-30 : 12:04:23
Brilliant Thanks James, that's worked
Go to Top of Page
   

- Advertisement -