Solved

Query Database For Table - Email that has a blank, missing, or no data

Posted on 2016-10-20
7
72 Views
Last Modified: 2016-11-02
I have a membership database.  One of the fields is "Email".  That field CAN be blank.  I'd like to query the database and find all member records with no data in the Email field.  That we can reach out to those members and ask them to update their e-mail address.

SQL database.  Thank you.
0
Comment
Question by:derrickisonline
7 Comments
 
LVL 43

Accepted Solution

by:
zephyr_hex (Megan) earned 500 total points
ID: 41852302
It's not entirely clear what you're looking for... but to find blank or NULL Email records, you would do:

SELECT * from MyTable WHERE Email IS NULL OR Email = ''

Open in new window

0
 

Author Closing Comment

by:derrickisonline
ID: 41852325
You stated you didn't know what I was looking for, but that was exactly it.  I just needed to know which records had a missing email address field.  That way we can reach out and have members update their email addresses.  

Thank you!
0
 
LVL 32

Expert Comment

by:awking00
ID: 41852330
Slight variation -
SELECT * from MyTable WHERE ISNULL(Email,'') = ''
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 20

Expert Comment

by:Russ Suter
ID: 41852334
I might slightly enhance what is above to perform at least a rudimentary search for a valid email address.
SELECT * FROM myTable WHERE Email IS NULL OR Email NOT LIKE '%_@__%.__%'

Open in new window

This at least guarantees that the email address will have a minimum of a single "@" and a single "."
This query would return empty, blank, and invalid email addresses.
0
 

Author Comment

by:derrickisonline
ID: 41852360
One more thing, can you tell me how to use the query you provided but drilling down again buy saying Membership Status = Active?
0
 
LVL 43

Expert Comment

by:zephyr_hex (Megan)
ID: 41852676
SELECT * from MyTable WHERE (Email IS NULL OR Email = '') AND [Membership Status] = 'Active'

Open in new window

1
 

Author Comment

by:derrickisonline
ID: 41870407
Thanks again!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question