Евгений Косов wrote:
NOW() BETWEEN sale_start AND sale_end
is equivalent to
sale_start <= NOW() AND sale_end >= NOW()
NOT(A AND B) is equivalent to (NOT A OR NOT B), so "NOW() NOT BETWEEN
..." is equivalent to "sale_start > NOW() OR sale_end < NOW()". Can
sale_start be greater than NOW() in your data? If not, we can
simplify to
SELECT prod_name, sale_price, sale_schedule_status
FROM products
WHERE sale_end < NOW()
AND sale_schedule_status = 'active';
Can sale_end be >= NOW()?
Michael
Are you sure? ;)
Yes, I am.
Let's see..
NOW() NOT BETWEEN sale_start AND sale_end =>
(There was a 'NOT' before BETWEEN in orginal post)
Yes, I saw that. "NOW() NOT BETWEEN..." is equivalent to "NOT(NOW()
BETWEEN...", as documented in the manual
<http://dev.mysql.com/doc/mysql/en/comparison-operators.html>.
=> NOT ( NOW() > sale_start AND NOW() < sale_end ) =>
No. BETWEEN is inclusive of its endpoints. (Same page in the manual). Hence
we start with
NOT (NOW() >= sale_start AND NOW() <= sale_end)
=> NOT (NOW() > sale_start) OR NOT ( NOW() < sale_end)
=> NOT (NOW() >= sale_start) OR NOT ( NOW() <= sale_end)
=> NOW() <= sale_start OR NOW() >= sale_end
=> NOW() < sale_start OR NOW() > sale_end
=> sale_start > NOW() OR sale_end < NOW()
Michael
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]