SQL Multiple Joins Query -
here have 2 tables committee_colleges , colleges. structure of tables this
committee_colleges
committeecollegeid collegeid committeememberid 1 2 1 2 2 2 3 3 2
i storing committeememberid committeemember table.and 1 college can have multiple committee members.how can wite query display colleges assigned specific committee member. example,if committeemember id=2 has logged in want display colleges id=2,3.
in college table have this,
collegeid typename 1 aicte 2 ncte 3 ntcs
this committee member table
committeememberid name 1 xyz 2 abc
now writing this,but know wrong because dont know how take college table since displaying college details.
select cc.committeecollegeid committeecollegeid, c.collegeid collegeid, cc.committeememberid committeememberid committee_college cc left outer join college c on cc.collegeid = c.collegeid cc.committeememberid=:committeememberid order cc.committeecollegeid asc
can tell how display colleges based on assignment particular committeemember?
you close, need inner join
instead of left join
:
select distinct c.typename --<<== put here columns want in output committee_colleges cc inner join college c on c.collegeid = cc.collegeid cc.committeememberid = 2 --<<== input parameter
edit: added distinct
hope helps.
Comments
Post a Comment