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 [email protected] [email protected] o
2 Jim Last [email protected] [email protected] x
3 Marc Johnson [email protected] [email protected] o
4 Nicole Someone @ [email protected] o
5 Hans Others [email protected] 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 [email protected]
3 Marc Johnson [email protected]
4 Nicole Someone [email protected]
5 Hans Others [email protected]
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 [email protected]
3 Marc Johnson [email protected]
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 [email protected] [email protected] o
2 Jim Last [email protected] [email protected] x
3 Marc Johnson [email protected] [email protected] o
4 Nicole Someone @ [email protected] o
5 Hans Others [email protected] 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 [email protected]
3 Marc Johnson [email protected]
4 Nicole Someone [email protected]
5 Hans Others [email protected]
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 [email protected]
3 Marc Johnson [email protected]
4 Nicole Someone @
5 Hans Others
Thanks for your help,
Niels