visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Databases :: MySql :: Intersects?


By: Squibi U.S.A.  Date: 29/07/2003 00:00:00  English  Points: 20 Status: Answered
Quality : Excellent
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
By: VGR Date: 29/07/2003 04:32:00 English  Type : Answer
select timetable_id from timetable as a, timetable as b
where a.location_id = '.location_id.' AND (b.start_date between '.$startdate.' and '.$enddate.'
or b.end_date between '.$startdate.' and '.$enddate.'");

personally, I don't like BETWEEN, I recommend a "normal" >= ... AND <=... test
By: psadac Date: 29/07/2003 07:19:00 English  Type : Comment
VGR, don't you need only one timetable (i think you make an unecessary cross join) ?
personnaly i prefer BETWEEN : you only write once the column name (i'm very lazy ;-)

SELECT timetable_id
FROM timetable
WHERE location_id = '.$location_id.'
AND (start_date BETWEEN '.$startdate.' and '.$enddate.' OR end_date BETWEEN '.$startdate.' and '.$enddate.');


Do register to be able to answer

EContact
browser fav
page generated in 293.131110 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page