Inner join help please

Hello,

Wondering if anyone could help me with a inner join query which is confusing me


SELECT photographic_schedule.user_id, photographic_users.name, photographic_schedule.appointment_type, photographic_schedule.live, photographic_schedule.the_date, photographic_schedule.event_begin_time, photographic_schedule.event_end_time
FROM photographic_schedule
INNER JOIN photographic_users ON photographic_schedule.user_id = photographic_users.user_id
WHERE photographic_schedule.appointment_type =98
OR photographic_schedule.appointment_type =99
AND photographic_schedule.live =1
AND photographic_schedule.the_date = '2011-03-17'

My problem being this part AND photographic_schedule.the_date = ‘2011-03-17’. Which it seems to ignore If I change this to any date, ie 2011-03-18, 2011-11-21 it still returns all results in my database regardless of the date?

Thanks

When you start using OR and AND in the WHERE conditions, it’s better to use parentheses to avoid unwanted results:


WHERE 
    (   photographic_schedule.appointment_type =98
     OR photographic_schedule.appointment_type =99 )
AND photographic_schedule.live =1
AND photographic_schedule.the_date = '2011-03-17'

In this case you could use IN instead of the two conditions with OR:


WHERE photographic_schedule.appointment_type IN (98, 99)
AND   photographic_schedule.live =1
AND   photographic_schedule.the_date = '2011-03-17'