[thelist] Iterate through result set - Is this possible? (SQL)
Burhan Khalid
thelist at meidomus.com
Tue May 31 01:33:21 CDT 2005
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