Jump to content


Photo

Query not going right


  • Please log in to reply
6 replies to this topic

#1 ErocM

ErocM
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 20 September 2006 - 03:58 PM

I have 3 tables that I am trying to query. 

Members - has user info to include  (UserId, Username)
MessageInfo -has (MessagetId, MessageFrom, MessageTo)
MessageText - (MessageId, PostText)

I want to query these together together and I'm not sure how to tie the 3 together. I can quest each individually but I'm having no success getting a query that incorporates them all. 

Anyone have any suggestions?

Thanks,
E

#2 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 20 September 2006 - 05:31 PM

You need to redesign the table so they have a common link

Members = fields Userid, username ect...
MessageInfo = fields MessageID, Userid, MessageFrom, MessageTo ect...
MessageText = MessageID, PostText ect...

By adding the Userid in the message info table you can now link like so:

Members.Userid = MessageInfo.Userid AND MessageInfo.MessageId = MessageText.MessageId

Hope that helps

Ray

#3 ErocM

ErocM
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 20 September 2006 - 06:25 PM

Sorry if it doesn't make sense I can do this on MSAccess since I'm more familiar with it, so I apologize if I sound ignorant on this...

Members = fields: Userid, username ect...
MessageInfo = fields: MessageID, Userid, MessageFrom, MessageTo ect...
MessageText = fields: MessageID, PostText ect...


Anyhow couldn't this be done:

- take the MessageInfo, which has the same field "MessageID", link to MessageText's "MessageId" to get the "PostText"
- then link the MessageInfo's "UserId" to the Members' "UserId" to get the "Username" for the "MessageFrom" and "MessageTo" ?

that being said and if it can be done, can anyone help me figure out how to do it?

Thanks,
E

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 21 September 2006 - 12:38 AM

As long as there is relationship between pairs of tables, you'll be fine.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 ErocM

ErocM
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 21 September 2006 - 01:04 PM

What do I use to "link" between the tables in a query though?  That is where I am lost....

Thanks again,
E

#6 ErocM

ErocM
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 21 September 2006 - 06:22 PM

Can anyone help me get started?

E

#7 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 22 September 2006 - 09:58 AM

What information do you ultimately want to retrieve back in this query?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users