• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 398
  • Last Modified:

How to query from multiple table

Hi, I have a database having some tables and I want to run a query which shows a result from multiple tables.
Tables Details:
Table 1. Groups (Columns: ID, Title)
Table 2. GroupMembership (Columns: GroupId, MemberId)
Table 3. UserInfo (Columns: tp_ID, tp_Title)
Group’s ID and GroupMembership’s GroupId having same entries so these two tables will interact on these columns and  GroupMembership’s MemberId and UserInfo’s tp_ID having same entries so these two tables will interact on these columns.
Please find the table structure in attach file.

Now a query gives result:
Title from Group and tp_Title from UserInfo table.
Kindly guide.





Tables.docx
0
Minesh Shah
Asked:
Minesh Shah
4 Solutions
 
OP_ZaharinCommented:
- try this:

SELECT b.GroupID, c.tp_Title
FROM Groups a
JOIN GroupMembership b ON b.GroupId = a.ID
JOIN UserInfo c ON c.tp_ID = b.MemberId

Open in new window

0
 
OP_ZaharinCommented:
- misread on Title from Group. the corrected one

SELECT a.Title, c.tp_Title
FROM Groups a
JOIN GroupMembership b ON b.GroupId = a.ID
JOIN UserInfo c ON c.tp_ID = b.MemberId
0
 
Pratima PharandeCommented:
select G.Title,U.tp_title
From Groups G,GroupMembership GM,UserInfo U
where G.ID = GM.GroupId and GM.MemberId = U.MemberId
0
 
Alpesh PatelAssistant ConsultantCommented:
Using Joins (Inner Join, Left/Right/FullOuter Join)
0
 
Minesh ShahSharePoint & all about itAuthor Commented:
thanks to all of you
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now