I got things working and then decided to UNION ALL one additional table, called notesOffline. I get the query to actually run when I use the ‘blank’ as uID, however, no results are actually included from this table because notesOffline doesn’t have a uID column. Is there any other way I can UNION ALL these tables together? Below is the query how I currently have it.
Thanks!
SELECT dateAdded
, dateAddedFormatted
, u.uID
, concat (firstName, ' ', lastName) as fullName
, memberType
, subscription
, sponsorID
, dateDue
, dateDueFormatted
, entryID
, source
, type
, topic
, entry
, status
, dateDue
FROM (SELECT answerDate as dateAdded
, date_format(answerDate, '%m-%d-%Y') as dateAddedFormatted
, uID
, cID AS entryID
, 'campaigns' AS source
, 'Campaign' as type
, type as topic
, answer AS entry
, status
, answerDate as dateDue
, date_format(answerDate, '%m-%d-%Y') as dateDueFormatted
FROM campaigns
WHERE status = 'Open' and (type = 'Enrollment' and uID in (select uID from users where sponsorID = 333 or sponsorID = 0) or type = 'Gold')
UNION ALL
SELECT dateAdded as dateAdded
, date_format(dateAdded, '%m-%d-%Y') as dateAddedFormatted
, 'blank' as uID
, nID as entryID
, 'notesOffline' AS source
, type
, topic as topic
, entry
, status
, dateDue
, date_format(dateDue, '%m-%d-%Y') as dateDueFormatted
FROM notesOffline
WHERE status = 'Open'
UNION ALL
SELECT dateAdded as dateAdded
, date_format(dateAdded, '%m-%d-%Y') as dateAddedFormatted
, uID
, cID as entryID
, 'communications' AS source
, type
, topic as topic
, entry
, status
, dateDue
, date_format(dateDue, '%m-%d-%Y') as dateDueFormatted
FROM communications
WHERE status = 'Open') SQ
JOIN users u
ON u.uID = SQ.uID
ORDER by dateDue;