B
brief4niels
Hallo All,
I have the following table with fields/columns and test data) called
tblExport03
ID FirstName LastName BusinessEmail PrivateEmail NoMail
1 Bob Bobson (e-mail address removed) (e-mail address removed) o
2 Jim Last (e-mail address removed) (e-mail address removed) x
3 Marc Johnson (e-mail address removed) (e-mail address removed) o
4 Nicole Someone @ (e-mail address removed) o
5 Hans Others (e-mail address removed) o
6 Tanja Big @ @ o
I want to select all persons who want e-mail (NoMail =o) and only have
one column with e-mail addresses... If a person has both a business and
private e-mail address then only use the business email address. If
there is no business e-mail address use the private e-mail address
(this is where it goes wrong)
This is the data I would like to see
ID FirstName LastName EmailAddress
1 Bob Bobson (e-mail address removed)
3 Marc Johnson (e-mail address removed)
4 Nicole Someone (e-mail address removed)
5 Hans Others (e-mail address removed)
Below is the SQL satement I have so far.... problem is that it doesn't
add the private e-mail address in to the EmailAddress column when there
is no or '@' BusinessEmail
SELECT ID, FirstName, LastName, BusinessEmailAddress AS EmailAddress
FROM tblExport03
WHERE (NoMassMailing=0) AND ((BusinessEmailAddress<>'@') OR(
(IsNull(BusinessEmailAddress) OR (BusinessEmailAddress='@') AND
(PrivateEmailAddress<>'@' ))))
UNION SELECT ID, FirstName, LastName, PrivateEmailAddress AS
EmailAddress
FROM tblExport03
WHERE (NoMassMailing=0) AND IsNull(BusinessEmailAddress) AND
(BusinessEmailAddress=PrivateEmailAddress)
I used the 'AS EmailAddress' twice which is probably the problem...
This is the data I get from the above SQL statement
ID FirstName LastName EmailAddress
1 Bob Bobson (e-mail address removed)
3 Marc Johnson (e-mail address removed)
4 Nicole Someone @
5 Hans Others
Thanks for your help,
Niels
I have the following table with fields/columns and test data) called
tblExport03
ID FirstName LastName BusinessEmail PrivateEmail NoMail
1 Bob Bobson (e-mail address removed) (e-mail address removed) o
2 Jim Last (e-mail address removed) (e-mail address removed) x
3 Marc Johnson (e-mail address removed) (e-mail address removed) o
4 Nicole Someone @ (e-mail address removed) o
5 Hans Others (e-mail address removed) o
6 Tanja Big @ @ o
I want to select all persons who want e-mail (NoMail =o) and only have
one column with e-mail addresses... If a person has both a business and
private e-mail address then only use the business email address. If
there is no business e-mail address use the private e-mail address
(this is where it goes wrong)
This is the data I would like to see
ID FirstName LastName EmailAddress
1 Bob Bobson (e-mail address removed)
3 Marc Johnson (e-mail address removed)
4 Nicole Someone (e-mail address removed)
5 Hans Others (e-mail address removed)
Below is the SQL satement I have so far.... problem is that it doesn't
add the private e-mail address in to the EmailAddress column when there
is no or '@' BusinessEmail
SELECT ID, FirstName, LastName, BusinessEmailAddress AS EmailAddress
FROM tblExport03
WHERE (NoMassMailing=0) AND ((BusinessEmailAddress<>'@') OR(
(IsNull(BusinessEmailAddress) OR (BusinessEmailAddress='@') AND
(PrivateEmailAddress<>'@' ))))
UNION SELECT ID, FirstName, LastName, PrivateEmailAddress AS
EmailAddress
FROM tblExport03
WHERE (NoMassMailing=0) AND IsNull(BusinessEmailAddress) AND
(BusinessEmailAddress=PrivateEmailAddress)
I used the 'AS EmailAddress' twice which is probably the problem...
This is the data I get from the above SQL statement
ID FirstName LastName EmailAddress
1 Bob Bobson (e-mail address removed)
3 Marc Johnson (e-mail address removed)
4 Nicole Someone @
5 Hans Others
Thanks for your help,
Niels