I have data such as:
tblBio
bio bioid
some data 1
some data 2
tblContact
email email_pub bioid
me@me.com 1 1
you@me.com 0 2
I need to select
bio + 'email: ' + email WHERE email_pub = 1
I currently have:
SELECT b.bio + 'Email: ' + COALESCE(c.email, '')
FROM tblbio b
INNER JOIN tblContact c ON b.bioid = c.bioid
WHERE c.email_pub = 1
AND b.bioid = 1
However, I ALWAYS need to select bio and then append the text ’email: ‘ as well as the email address onto the end ONLY if email_pub is set to 1. Having the ‘WHERE email_pub = 1’ makes it so that if email_pub is 0 then nothing is selected.
As well, the text ‘Email: ‘ will always show even if there is no published email.
Thank you,
Thomas
Use a
CASE: