Is there a better way to do this?
SELECT subs. * ,
CASE subs.member_type
WHEN 'member' THEN
( SELECT CONCAT_WS( ' ', members.first_name, members.last_name )
FROM members
WHERE members.id = subs.member_id)
ELSE
( SELECT members_anon.username
FROM members_anon
WHERE members_anon.id = subs.member_id)
END AS fullname,
CASE subs.member_type
WHEN 'member' THEN
( SELECT members.email
FROM members
WHERE members.id = subs.member_id)
ELSE
( SELECT members_anon.email
FROM members_anon
WHERE members_anon.id = subs.member_id)
END AS email
FROM subs
WHERE subs.item_id =19
AND subs.item_type = 'blog'
LIMIT 0 , 30
Ideally I would like to have only one CASE
section that returned name and email from the relevant table.