PDA

View Full Version : Confused about a multi table query


guvenck
02-13-2006, 08:09 AM
Hello,

I have 3 tables with following information:

Table A (here I keep just the ID's and the title of the event)
> ID, title
exp:
1 End of the year
3 Father's Day
8 Mother's Day

Table B (here I keep the date info of events happening in years):
> ID, year, month, day
exp:
1 2006 12 31
3 2006 6 18
8 2006 5 14
3 2007 6 17
8 2007 5 13
1 2007 12 31

Table C (and a last table, where I keep which events my members have added to their agenda.)
> usrid, eventID
2 3
2 8
7 3
7 1


I am looking for the query that will pull the records of which events the member has added for this month. Or better said, if there are events occuring this month, that the user has added to his agenda.

$curmonth = date("n");

My mind is confused and I don't think I can find the correct query, please help.

shyam
02-13-2006, 10:16 AM
something like this
select * from tablea a join tableb b on a.id=b.id and b.month=? join tablec c on a.id=c.eventID and c.usrid=?