Problem Query

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Problem Query

Post by Benjamin »

I dunno why this doesn't work, it looks fine to me. Here the echo'd query...

(Bolded for easy reading)


select CommentsIndex.CommentID, CommentsIndex.MemberID, `TimeStamp`, `CommentBody`, `PostCount`, `MemberUsername`, `ImageOne`, `One`, `Two`, `Type`
from `CommentsIndex`
join `Comments`
on (CommentsIndex.CommentID = Comments.CommentID)
join `PostCount`
on (CommentsIndex.MemberID = PostCount.MemberID)
join `Index`
on (CommentsIndex.MemberID = Index.MemberID)
join `Pictures`
on (CommentsIndex.MemberID = Pictures.MemberID)
join `Profile` on (CommentsIndex.MemberID = Profile.MemberID)
where CommentsIndex.CommentID='1199'


Error returned is syntax error near 'Index . MemberID
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

All tables and fields exist? That's my first check.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

index is a keyword.. backticks all around.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Yeah it needed backticks. For some reason I thought you didn't need backticks when specifying the table.fieldname.
Post Reply