Hello, bare with me on this one 3 tables users - id(int) username(varchar) articles - id(int) text(text) read - id(int) uid(int) aid(int) read(varchar default false) uid=id of the user that marked the article as read aid=marked article So users see a list of articles and have the option to mark it as read. Once they do this it should not show on the article list page. I`m currently selecting all from articles and for each article I check to see if the current logged user marked it as read or not. Problem is I have 1 query that selects the articles and for each row returned another query that checks against the read table. Any suggestions? There has to be a easier way but I just can`t find it..
why not just left join it: select * from user u left join read r on r.uid=u.id left join articles a on a.id=r.aid where u.id= 'userid' then the column 'read' will indicate if the article has been read or not
But if i have 2 users 10 articles and no reads, wouldn`t that return 0 rows? I want to select the articles that are not read by the current user, not the ones that are.
SELECT * FROM `articles` LEFT JOIN `read` ON `read`.`aid` = `articles`.`id` AND `read`.`uid` = [i]insert user_id here[/i] WHERE `read`.`read` IS NULL OR `read`.`read` = 'false' Code (markup):