Any idea why I’m getting the error of, “Unknown column ‘ID’ in where clause” when I don’t even mention ID in the where clauses at all? This really has me stumped! Especially since the code works fine when I run it in Querious for the Mac.
Thanks!
SELECT uID as ID
, m.dateAdded AS sortDate
, concat(firstName, ' ', lastName) as senderName
, m.type
, m.message
, 'Online' as source
, case when dateDiscovered is not null then 'Yes' else 'No' end as discovered
, case when dateViewed is not null then 'Yes' else 'No' end as viewed
, upgradeNeeded
FROM users u
INNER JOIN messagesOnline m
ON u.uID = m.senderID
WHERE date(dateAdded) = '$statDate'
UNION
SELECT 'ID' as ID
, dateAdded AS sortDate
, concat(firstName, ' ', lastName) as senderName
, type
, message
, 'Offline' as source
, case when dateDiscovered is not null then 'Yes' else 'No' end as discovered
, case when dateViewed is not null then 'Yes' else 'No' end as viewed
, upgradeNeeded
FROM messagesOffline
WHERE date(dateAdded) = '$statDate'
ORDER by sortDate desc