I’m having some issues getting the following query to work – in all cases I only seem to get a small subset of users back rather than the entire list.
I have the following two tables:
Users:
- UserId
- email
Updates:
- UserId
- Status
- LastUpdated
What I want to be returned is a list of all users (from Users), their status if it was updated today (based on LastUpdated field) otherwise BLANK or NULL if it wasn’t updated today.
I’ve got as far as this:
SELECT users.userid,
updates.status
FROM users
LEFT JOIN updates
ON users.userid = updates.userid
WHERE Date(lastupdated) = Date(Now())
You can use a
CASEstatement to only getupdates.statusif the date is today:Or, better yet, if you don’t need anything else from the
updatesrow just do: