Reputation: 5554
The query is:
SELECT COUNT (*) FROM Production AS p LEFT OUTER JOIN Estimates ON
p.EstId=Estimates.EstId WHERE p.DocketNumber=20227
When I enter literally this query into PHPMySQLAdmin, it executes and gives me a result. When I enter this query into PHP code, it brings up an error. There is no problem connecting to the database, because when I remove COUNT and the brackets around *, the query executes.
Is this an issue with mysql and conflicts with the count command?
EDIT: nvm
Upvotes: 1
Views: 204
Reputation: 562368
MySQL has an option for whether to accept COUNT (*)
or whether to insist that there be no space. This option can be set per database connection, so it might be set differently in your phpMyAdmin connection versus your PHP connection.
So SELECT COUNT (*) ...
might be an error or not, depending on the SQL mode. It's usually more correct to use SELECT COUNT(*) ...
without the space after COUNT
.
See Function Name Parsing and Resolution for more details.
Upvotes: 1
Reputation: 78916
remove the space between count and the brackets
select count(*) ...
then your query looks syntactially correct. are you absolutely positive you copied the exactly this sql statement into phpmyadmin and into your php code? coz my phpmyadmin doesn't like spaces between count and the brackets either...
#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 '*) from tablename LIMIT 0, 30' at line 1
Upvotes: 0