PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 9th, 2012, 12:03 PM
syedmahtab syedmahtab is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 2 syedmahtab User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 57 sec
Reputation Power: 0
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
[array (
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,

Mahtab Hussain

Reply With Quote
  #2  
Old July 9th, 2012, 02:50 PM
shammat shammat is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Oct 2003
Location: Germany
Posts: 2,685 shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level)shammat User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 3 Days 19 h 53 m 13 sec
Reputation Power: 284
end is a reserved word.

This should work:
Code:
SELECT * 
FROM mdl_trainings 
WHERE manager_id = $1 
AND "end" IS NULL


And please use [code] tags in the future to format your SQL code.
__________________
I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
http://forums.devshed.com/misc.php?do=bbcode#code

Tips on how to ask better questions:
http://tkyte.blogspot.de/2005/06/how-to-ask-questions.html
http://wiki.postgresql.org/wiki/SlowQueryQuestions
http://catb.org/esr/faqs/smart-questions.html

Reply With Quote
  #3  
Old July 10th, 2012, 11:47 AM
syedmahtab syedmahtab is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2012
Posts: 2 syedmahtab User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 57 sec
Reputation Power: 0
Quote:
Originally Posted by shammat
end is a reserved word.

This should work:
Code:
SELECT * 
FROM mdl_trainings 
WHERE manager_id = $1 
AND "end" IS NULL


And please use [code] tags in the future to format your SQL code.


Thanks Shammat. You were exactly right. I have renamed the field names to avoid reserved word and updated relevant code. It solved my issue.

Thanks once again.

Regards,
Mahtab

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > Syntax Error Help

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap