Can anyone please advise on the use of SUBDATE as I am clearly missing something.
I have a table (see below) and I want to know what deliveries have been made in August. Deliveries are considered delivered when a delivery note number is added to the deliveryNoteNumber column. I have included what I think the code should be and the RESULT I am expecting.
At the bottom is the error I get when I run the query in phpMyAdmin. I've tried all sorts of combinations with the same error. Thanks in antisipation. Steve
TABLE delivery
deliveryId deliveryNoteNumber deliveryDate
----------+------------------+------------+
1 3001 2008-07-07
2 3005 2008-08-08
3 3002 2008-09-09
4 0 2008-08-10
SELECT * FROM delivery WHERE deliveryNoteNumber > '0' AND deliveryDate SUBDATE('2008-08-31', INTERVAL 1 MONTH)
RESULT
deliveryId deliveryNoteNumber deliveryDate
----------+------------------+------------+
2 3005 2008-08-08
ERROR
#1064 - 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 'SUBDATE( '2008-08-31' , INTERVAL 1 MONTH )
LIMIT 0, 30' at line 1
I have a table (see below) and I want to know what deliveries have been made in August. Deliveries are considered delivered when a delivery note number is added to the deliveryNoteNumber column. I have included what I think the code should be and the RESULT I am expecting.
At the bottom is the error I get when I run the query in phpMyAdmin. I've tried all sorts of combinations with the same error. Thanks in antisipation. Steve
TABLE delivery
deliveryId deliveryNoteNumber deliveryDate
----------+------------------+------------+
1 3001 2008-07-07
2 3005 2008-08-08
3 3002 2008-09-09
4 0 2008-08-10
SELECT * FROM delivery WHERE deliveryNoteNumber > '0' AND deliveryDate SUBDATE('2008-08-31', INTERVAL 1 MONTH)
RESULT
deliveryId deliveryNoteNumber deliveryDate
----------+------------------+------------+
2 3005 2008-08-08
ERROR
#1064 - 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 'SUBDATE( '2008-08-31' , INTERVAL 1 MONTH )
LIMIT 0, 30' at line 1