[thelist] SQL query question (easy)
April
april at farstrider.org
Tue May 9 23:13:02 CDT 2006
I have start_on and end_on dates, which can also be null. I'm writing a
SQL select to find all instances where a date is within the start_on,
end_on range and but returns if one or the other is null too. If the
start_on is null and the end_on is greater than the date, then it needs
to return.
Basically, I need to combine:
start_on <= now() AND end_on >= now()
with:
start_on IS NULL AND end_on IS NULL
start_on IS NULL AND end_on >= now()
start_on <= now() AND end_on IS NULL
It looks like I could do this with three unions (haven't tested), but is
that the best way to do this? With the other conditions thrown in,
that'd be an incredibly long query (which is usually a sign I'm doing
something wrong).
Thanks for any help,
April
More information about the thelist
mailing list