On Wed, 13 Jul 2005 00:34:15 -0400, wrote: >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 Could we have the corrected sql here pls?
I guess SELECT IF(NOW()) BETWEEN sale_start AND sale_end,'no','yes') another example SELECT IF(STRCMP('test','test1'),'no','yes'); -> 'no' -- zzapper vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?" http://www.rayninfo.co.uk/tips/ vim, zsh & success tips -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]