Jump to content

Simple join help?


scotchegg78

Recommended Posts

Hi guys

 

I have this query.

 

SELECT pal_member.name as name,pal_member.id as id,pal_member.dob as dob FROM pal_member,pal_friends WHERE (WEEK(dob) = WEEK(DATE_ADD(CURDATE(),INTERVAL 3 DAY))) AND (pal_friends.pal_1 = '97' OR pal_friends.pal_2 = '97')

 

where I am attempting to get all members with a birthday upcoming in the next 10 days, ofwhich I am friends with.

It uses the pal_members table and the pal_friends table which links the id's.

 

However the current call gets all the birdthday people right, but messes up the friends part and i get to much data.

I think it needs a join of some sort , but I am confused as i am not joining on ids from both tables.

 

My train of thought was simple get the data from the members table with upcoming birdthdays, then filter this against seeing if the members id is paired up in the friends table?

 

any ideas on this, as I can not quite get my head around this join

 

many thanks for any tips

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.