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? ;)

Let's see..


NOW() NOT BETWEEN sale_start AND sale_end  =>
(There was a 'NOT' before BETWEEN in orginal post)

=> NOT ( NOW() > sale_start AND NOW() < sale_end ) =>

=> NOT (NOW() > sale_start) OR NOT ( NOW() < sale_end) =>

=> NOW() <= sale_start OR NOW() >= sale_end


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to