Create a view from multiple tables
750180Feb 3 2010 — edited Feb 3 2010Hi all,
I am a newbie, so sorry if this is a "basic" question.
I had 3 tables TAB1, TAB2 and TAB3
TAB1 has
STU_ID(pk), NAME, GRADE, ADDRESS
TAB2 has
COURSE_ID(pk), STU_ID(fk), COURSE_NAME, ROOM_NUM, TIME, DAY
TAB3 has
MENTOR_NAME, TITLE, AVAILABLE_DAYS
Now I want to create a view(or query) that returns STU_ID, COURSE_NAME, NAME, GRADE, MENTOR_NAME and TITLE.
When I tried writing a query like
SELECT a.STU_ID, b.COURSE_NAME, a.NAME, a.GRADE, c.MENTOR_NAME, a.TITLE
FROM TAB1 a, TAB2 b, TAB3 c
WHERE a.STU_ID=b.STU_ID
I am getting multiple results..like I'm getting Mentor name 4 times, name 4 times like that.
So can anybody help me in writing the query for this....a "VIEW" would be appreciated.
Thanks In Advance
Srra