Scott Haneda wrote:
I can not get this to work how I would think it should be formatted:
SELECT IF(NOW() BETWEEN sale_start AND sale_end, 'yes', 'no')
That seems to work just fine

It should, as that is correct syntax, as documented in the manual <http://dev.mysql.com/doc/mysql/en/comparison-operators.html>.

However, I was under the impression that BETWEEN was to be formatted
BETWEEN(va1, v2)

Where did you get that idea?

Which leads me to:
SELECT IF(NOW() BETWEEN(sale_start AND sale_end), 'yes', 'no')
Which gives me a error of:
You have an error in your SQL syntax. Check the manual that corresponds to
your MySQL server version for the right syntax to use near ' 'yes', 'no')
FROM products WHERE id = "75"

This is invalid syntax, hence the error message. Mysql expects "BETWEEN min_value AND max_value". Your parentheses mean that min_value is the result of (sale_start AND sale_end), which will be 0 (false) if either sale_start or sale_end is 0, otherwise it will be 1 (true). Then you are missing the 'AND max_value' part.

Michael

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

Reply via email to