Hi,
I may have misunderstood, but it would seem that you found the error in your query.
However, you are here asking a question about an error in a SQL query, but you are not saying exactly what the query is, nor is it the exact error.
Apart from the fact that this forum is not intended to debug PHP scripts or SQL queries from Wampserver users, if you do not give any relevant details, you can not guess.
---------------------------------------------------------------
Documentation Apache -
Documentation PHP -
Documentation MySQL -
Wampserver install files & addons