Syntax Error Help
May you all live in peace!
I have a little problem and I am very hopeful that I will get a solution over here.
I have created a php page which runs this SQL statement:
SELECT * FROM mdl_trainings WHERE manager_id = $1 AND end IS NULL
0 => '15',
Here is the error I receive,
"Error Reading Database"
Debug info: ERROR: syntax error at or near "end"
I hope someone here can definitely guide me what syntax error is there in the statement and how can I correct that.
Note: The same statement works perfect for MySQL database but does not work for PostgreSQL database.
With warm regards,
end is a reserved word.
This should work:
And please use [code] tags in the future to format your SQL code.
WHERE manager_id = $1
AND "end" IS NULL
I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
Tips on how to ask better questions:
July 10th, 2012, 11:47 AM
Thanks Shammat. You were exactly right. I have renamed the field names to avoid reserved word and updated relevant code. It solved my issue.
Originally Posted by shammat
Thanks once again.