I have the following query working on sql server managemengt studio but it does not seem to work on phpmyadmin, Can anyone figure out what is wrong, It gives this error message “#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 ‘1 google_rank FROM eig_ranking mi WHERE mi.project_id = m.project_’ at line 7”
I am using MySQL Version : 5.5.20 and php Version 5.3.13 and microsoft server 2008
SELECT project_id,
google_rank,
COALESCE(
(
SELECT TOP 1 google_rank
FROM eig_ranking mi
WHERE mi.project_id = m.project_id
ORDER BY
project_id
), 0 - google_rank AS movement
,keyword
,domain
FROM eig_ranking m where DATEDIFF(WEEK,rank_date, GETDATE())= 1 and google_rank!=0
order by movement desc
It your database is MySQL, then you need to write MySQL syntax and not Microsoft SQL Server syntax – replace
TOPwithLIMIT, andDATEDIFFarguments with the MySQL format,GETDATE()withNOW(), etc.