Gossamer Forum
Home : General : Databases and SQL :

here goes sql statement

Quote Reply
here goes sql statement
Hi I'm making a forum, and I have a problem with an sql statement.

I don't know if I can show it right but it's worth a shot. Here's a simplified version

MyPostTable:
PID
PostSubject
DatePosted
UserID

MyForumTable:
FID
ForumName

MyDicussionTable:
DID
ForumID (Linked To FID of my forum)
PostID(linked to the PID in MyPostTable)
LastPostID(Also Linked to the PID in MyPostTable)

MyUserTable:
UID
Username

Now here's what I'm looking for. I want to select my Discussions and Return
  1. PostSubject
  2. Username of The user who started the discussion
  3. Username of the user who last posted in the discussion
  4. DatePosted of the user who last posted in the discussion


My problem is that I want 2 different usernames right, and I'm linking from myDiscussion table through MyPOst table to my usertable.
So how do I return 2 different username in one query and attach the datePosted to the User who last posted.

This is an issue I've run into many time but could never find a good SQL statement and end up always having to redidesign my table. SO I would be forever grateful to whomever would take time to help me.

Thanks a Million in advance.



Dan
Subject Author Views Date
Thread here goes sql statement dan2003 4305 Feb 8, 2003, 10:41 PM
Thread Re: [dan2003] here goes sql statement
dan2003 4077 Feb 9, 2003, 11:48 AM
Post Re: [dan2003] here goes sql statement
Stealth 4012 Feb 10, 2003, 8:44 AM