[thelist] Iterate through result set - Is this possible? (SQL)
Burhan Khalid
thelist at meidomus.com
Tue May 31 02:45:45 CDT 2005
Ken Schaefer wrote:
> Hi,
>
> Your current requirements are ambiguous (because you can have multiple events
> that have a start date > 7 days after any given event start date)
Yes I understand this, but I need the first available 7 day gap for a
given hall, not a listing of all the events whose gap is 7 days or more.
Sorry I didn't make this clear before.
> Can you post a set of sample data, and what your expected output is? If you
> can provide that, then we can write the necessary SQL (if it's possible) to
> generate the output.
I'll have to get remote access, but I'll post as soon as I can get it.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> : From: thelist-bounces at lists.evolt.org [mailto:thelist-
> : bounces at lists.evolt.org] On Behalf Of Burhan Khalid
> : Subject: [thelist] Iterate through result set - Is this possible? (SQL)
> :
> : Hello Everyone:
> :
> : I've run into a bit of a logic problem with SQL, and I don't think
> : the solution is with SQL. Hopefully someone can clear this up.
> :
> : 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)
> :
> : So far, I've managed to get the correct start dates for all events
> : that are in a particular hall with the following (MySQL):
> :
> : SELECT start_date FROM events WHERE id IN (SELECT eventid FROM
> : halls_events WHERE hallid = 2);
> :
> : What I would like to do is something like :
> :
> : SELECT start_date FROM events WHERE id IN (SELECT eventid FROM
> : halls_events WHERE hallid = 2) AND DATEDIFF(start_date,start_date) > 7;
> :
> : Basically, loop through the results and compare each pair of
> : start_dates. The above doesn't work. Is this something that I need to
> : solve on the server side? Or am I missing some SQL magic?
> :
> : Thanks,
> : Burhan
>
More information about the thelist
mailing list