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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.