luiz Rafael wrote:
SELECT * FROM `sav00_sava0400_dbf` WHERE 2000 = YEAR(`emissao`) OR (1999 = YEAR(`emissao`) AND 12 < MONTH(`emissao`)) ORDER BY emissao ASC
Are you sure this is what you really want? MONTH() is never greater than 12, so your query is equal to: SELECT * FROM `sav00_sava0400_dbf` WHERE 2000 = YEAR(`emissao`) ORDER BY emissao

In order to make your query work faster you should create an index on `emissao` and rewrite it using date ranges. So you query will become something like this (if you actually meant December'99 and whole year 2000): SELECT * FROM `sav00_sava0400_dbf` WHERE `emissao` BETWEEN '1999-12-01 00:00:00' AND '2000-12-31 23:59:59';

--
BR,
Eugene Kosov

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

Reply via email to