Databases :: MySql :: Intersects? |
|||
| By: Squibi |
Date: 29/07/2003 00:00:00 |
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 | 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 | 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 |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








