Jump to content

mysql - join 2 tables but 2nd may not always exist, php solution or something?


mosi

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.