mosi Posted July 12, 2007 Share Posted July 12, 2007 Not sure if this is better in mysql or here, but I figured here in the end. I have two tables: Calendar -day -month -year -contentID Read -contentID -userID When a user is logged in I have the calendar check all days for the current month thats showing. This then links to the conentID in the database for that day. What I want is to be able to combine this with the Read table so that if a user has already read that contentID then it wont link or show it not in bold or something. I current have it so that when a user reads that contentID it adds the current userID and contentID to the Read table. The problem I'm having is how I can easily check if a user has read a certain contentID without running a mysql query everytime the calendar's while loop goes round to get calendar data just to check if the row exists. Can I do a JOIN somehow even when the 2nd table may not contain any data to join it with? What I want to be able to do from this is allow me to colour the calendar cells a different colour if the user has read a contentID already. Hope all that makes sense Quote Link to comment Share on other sites More sharing options...
Barand Posted July 12, 2007 Share Posted July 12, 2007 SELECT c.day, c.month, c.year, r.user FROM calendar c LEFT JOIN read r ON c.contentID = r.contentID IF there is nor matching 'read' record the r.user will be NULL Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.