Bug #614 Multiple EXTRACT() WHERE conditions on same column fail without quoting
Submitted: 6 Jun 2003 12:29 Modified: 11 Jun 2003 10:10
Reporter: Dean Ellis Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.14 OS:Linux (Linux)
Assigned to: Alexey Botchkov CPU Architecture:Any

[6 Jun 2003 12:29] Dean Ellis
Description:
Mutliple EXTRACT() conditions against the same column fail in the WHERE clause unless using string comparison.

How to repeat:
CREATE TABLE extest ( exdate DATETIME );
INSERT INTO extest VALUES ( '2003-06-06' );
-- These two are fine
SELECT exdate FROM extest WHERE EXTRACT(year from exdate) = 2003;
SELECT exdate FROM extest WHERE EXTRACT(month from exdate) = 6;
-- Combining them fails
SELECT exdate FROM extest WHERE EXTRACT(year from exdate) = 2003 AND EXTRACT(month from exdate) = 6;
-- Comparing as strings works
SELECT exdate FROM extest WHERE EXTRACT(year from exdate) = '2003' AND EXTRACT(month from exdate) = '6';
[11 Jun 2003 10:10] Alexey Botchkov
Thank you for your bug report. This issue has been fixed in the latest
development tree for that product. You can find more information about
accessing our development trees at 
    http://www.mysql.com/doc/en/Installing_source_tree.html