If I开发者_如何学C have table 1 with fields Groupid and Branchid amonst others, table 2 with fields Group id and Groupname amongst others and table 3 with fields Branchid and Branchname amongst others, how do I join these tables?
natural join does not work.
SELECT foo
FROM Table1
JOIN Table2 ON Table2.GroupID = Table1.GroupID
JOIN Table3 ON Table3.BranchID = Table1.BranchID
This is what the query should likely be typically. Is this different that what you have?
(SQL Server syntax)
SELECT Column1, Column2...
FROM GroupBranch_Rel
INNER JOIN Groups
ON Groups.GroupID = GroupBranch_Rel.GroupID
INNER JOIN Branches
ON Branches.BranchID = GroupBranch_Rel.BranchID
精彩评论