I got an question about mysql. Is it possible to check if an row exists in an external table?
For example, I need to show recent uploaded images and I would like to show some userdata with it and show if the user is online.
My current query is:
SELECT `users`.`username`, `users`.`location`, `users`.`age`, `users`.`dateofbirth`
FROM (`images`)
JOIN `users`
ON `users`.`userid` = `images`.`userid`
WHERE `images`.`active` = 1
LIMIT 12
But I’m missing the ‘is online’ part. Is it possible to use this in the select? For example if the row exists there would be a value in the select named online and it’s value = 1 and if user is not online (no row in table) the value needs to be 0. Is that possible?
Seems like you just need to use a
LEFT JOINon the other table and then aCASEto provide the value: