[thelist] Iterate through result set - Is this possible? (SQL)

Maximillian Schwanekamp lists at neptunewebworks.com
Tue May 31 02:58:42 CDT 2005

Burhan Khalid wrote:
>   I want to find the two sets of dates that differ by atleast 7 days.
>   There are two tables, halls_events (hallid, eventid) and events (id, 
> name, start_date, end_date)

Ken is right, some sample data and desired output would make this a lot 
easier on us.  But here's a late-night guess you might try:

SELECT ev1.start_date
FROM events ev1, events ev2, halls_events he
WHERE ev1.id = he.eventid
AND TO_DAYS(ev1.start_date) - TO_DAYS(ev2.start_date) > 7
AND he.hallid = 2

I'm tired, so this might be completely off.  The main thing is that you 
need to join the events table to itself to get the datediff, and limit 
the results of that to events happening where hallid=2.

Maximillian Von Schwanekamp

More information about the thelist mailing list