[thelist] SQL query question (easy)
Ken Schaefer
Ken at adOpenStatic.com
Tue May 9 23:21:12 CDT 2006
A Union is unnecessary, you should just be able to use OR
WHERE
(Start_On <= Now() AND End_On >= Now())
OR
(Start_On <= Now() AND End_ON IS NULL)
OR
...
Cheers
Ken
: -----Original Message-----
: From: thelist-bounces at lists.evolt.org [mailto:thelist-
: bounces at lists.evolt.org] On Behalf Of April
: Sent: Wednesday, 10 May 2006 2:13 PM
: To: thelist at lists.evolt.org
: Subject: [thelist] SQL query question (easy)
:
: 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