Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Intersects?

Status
Not open for further replies.

bluedollar

Programmer
Joined
Jul 24, 2003
Messages
174
Location
GB
I am using mysql with PHP and I want to do the following:

select timetable_id
from timetable
where location_id = '.location_id.'
intersect
select timetable_id
from timetable
where start_date between '.$startdate.' and '.$enddate.'
or end_date between '.$startdate.' and '.$enddate.'";

Anything between '..' are elements on my form.

The query above is coming up with an error, so I guess that mysql does not support intersects yet. Is there a way of acheiving the above without using an intersect?

Any help would be greatly appreciated.

Thanks

Dan

 
Have you tried:

select timetable_id
from timetable
where location_id = <location_id> and
(start_date between <startdate> and <enddate>
or end_date between <startdate> and <enddate>)

?

The parentheses may not even be necessary, but I don'd know for sure what operator precedence is in MySQL.


Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top