Try using IN(Month(Now()), Month(Now()) -1)
-----Original Message----- From: mayuran To: [EMAIL PROTECTED] Sent: 5/3/04 10:15 AM Subject: WHERE clause problem This is my table: mysql> desc testing; +-------+------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+------+------+-----+---------+-------+ | date | date | YES | | NULL | | +-------+------+------+-----+---------+-------+ Here are the values: mysql> select *from testing; +------------+ | date | +------------+ | 2004-04-10 | | 2004-04-15 | | 2004-01-01 | +------------+ Here is my question: The following query returns incorrect rows and I dont understand why. mysql> SELECT * FROM testing WHERE MONTH(date) = (MONTH(NOW()) OR MONTH(NOW())-1); +------------+ | date | +------------+ | 2004-01-01 | +------------+ I wanted the query to return the rows whose months are from this month or last month. This query however, returns the correct rows: mysql> SELECT * FROM testing WHERE MONTH(date) = MONTH(now()) OR MONTH(date) = MONTH(NOW())-1; +------------+ | date | +------------+ | 2004-04-10 | | 2004-04-15 | +------------+ Why does the first one not work? its shorter to type :) Thanks -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]