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

Ken Schaefer Ken at adOpenStatic.com
Tue May 31 02:09:52 CDT 2005


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)

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.

Thanks.

Cheers
Ken

--
www.adOpenStatic.com/cs/blogs/ken/ 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: 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