0

hi all,
I need to join three tables
my tables are

___________
markmaster
___________
stuid
subid
examcode
mark
___________
_____________
subjectmaster
_____________
subid
subname
subtype
externalmark
internalmark
_____________
___________
exammaster
___________
examcode
examname
duration
description
____________

I need result like stuid,subname,subtype,examname,mark . Could any one guide to write query for that
Thanks in advance

2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by anand01
1

Whenever you need to join tables you use the JOIN command and then specifiy which columns in the joined table form the linkage (are the same).
For your tablesto get stuid and subname the query would be:

SELECT mm.stuid, sm.subname FROM markmaster AS mm JOIN subjectmaster AS sm ON mm.subid = ms.subid;

The AS command lets you give shorter aliases to a table if you didn't already know. And you can specify a WHERE clause on the end if you need to. You should be able to add in the exammaster table from there, just use another JOIN and ON statement.

Votes + Comments
Short and sweet and a good example.
0

thanks for your reply hericles,
I know about join operations I don't know how to join 3 tables,
I need stuid from markmaster ,subname from subjectmaster ,subtype from subjectmaster ,examname from exam master ,mark from markmaster .
could you tel me how can I achieve that ..

0

To JOIN a third table just add another 'JOIN tableName' and another 'ON...'

SELECT mm.stuid, mm.mark, sm.subname, sm.subtype, em.examname FROM subjectmaster AS sm JOIN markmaster AS mm ON sm.subid = mm.subid JOIN exammaster AS em  ON sm.examcode = em.examcode;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.