ErocM Posted September 20, 2006 Share Posted September 20, 2006 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 Link to comment https://forums.phpfreaks.com/topic/21429-query-not-going-right/ Share on other sites More sharing options...
craygo Posted September 20, 2006 Share Posted September 20, 2006 You need to redesign the table so they have a common linkMembers = fields Userid, username ect...MessageInfo = fields MessageID, [b]Userid[/b], 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.MessageIdHope that helpsRay Link to comment https://forums.phpfreaks.com/topic/21429-query-not-going-right/#findComment-95548 Share on other sites More sharing options...
ErocM Posted September 20, 2006 Author Share Posted September 20, 2006 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...[b]Members = fields: Userid, username ect...MessageInfo = fields: MessageID, Userid, MessageFrom, MessageTo ect...MessageText = fields: MessageID, PostText ect...[/b]Anyhow couldn't this be done:- take the MessageInfo, which has the same field "[b]MessageID[/b]", link to MessageText's "[b]MessageId[/b]" to get the "[b]PostText[/b]" - then link the MessageInfo's "[b]UserId[/b]" to the Members' "[b]UserId[/b]" to get the "[b]Username[/b]" for the "[b]MessageFrom[/b]" and "[b]MessageTo[/b]" ?that being said and if it can be done, can anyone help me figure out how to do it?Thanks,E Link to comment https://forums.phpfreaks.com/topic/21429-query-not-going-right/#findComment-95587 Share on other sites More sharing options...
fenway Posted September 21, 2006 Share Posted September 21, 2006 As long as there is relationship between pairs of tables, you'll be fine. Link to comment https://forums.phpfreaks.com/topic/21429-query-not-going-right/#findComment-95770 Share on other sites More sharing options...
ErocM Posted September 21, 2006 Author Share Posted September 21, 2006 What do I use to "link" between the tables in a query though? That is where I am lost....Thanks again,E Link to comment https://forums.phpfreaks.com/topic/21429-query-not-going-right/#findComment-96036 Share on other sites More sharing options...
ErocM Posted September 21, 2006 Author Share Posted September 21, 2006 Can anyone help me get started?E Link to comment https://forums.phpfreaks.com/topic/21429-query-not-going-right/#findComment-96193 Share on other sites More sharing options...
fenway Posted September 22, 2006 Share Posted September 22, 2006 What information do you ultimately want to retrieve back in this query? Link to comment https://forums.phpfreaks.com/topic/21429-query-not-going-right/#findComment-96592 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.