What is wrong with this SQL query?

General discussion on PHP
Post Reply
sona3547
Posts: 1
Joined: Mon Jun 27, 2016 9:00 am

What is wrong with this SQL query?

Post by sona3547 » Mon Jun 27, 2016 9:02 am

SELECT Id, YEAR(BillingDate) AS BillingYear
FROM Invoices
WHERE BillingYear >= 2010;

i am building a small web site in php and the back hand using sql
i am stuck here pls tell me what to do now

thanks in advance

User avatar
zvika
Zend Global Support
Posts: 997
Joined: Sun Dec 14, 2008 9:48 am
Contact:

Re: What is wrong with this SQL query?

Post by zvika » Mon Jun 27, 2016 12:38 pm

Hi
What is the MySQL error?
Are you sure the WHERE clause accepts a calculated value before it is actually calculated?
Try to use 'WHERE YEAR(BillingDate) >= 2010' and see if it works.
I didn't check that, but if this fails, I will :)
Zvika Dror
Zend Support Team

rob6279
Posts: 4
Joined: Tue Mar 20, 2018 11:44 am

Re: What is wrong with this SQL query?

Post by rob6279 » Tue Mar 20, 2018 12:04 pm

Can you print out the error it is reading?

Post Reply