0

can l plz ask you something ... l hav a database with 4 tables i.e

User(fname, lname,email and userid ------primary key{userid} )

Exam( examid, examname-------primary Key{userid})

Exam_user(examid, userid------primary key{examid})

Exam_category(categoryid, categoryname----prmary key{categoryid})


HOW CAN YOU WRITE AN SQL QUERY THAT ALLOWS U TO CREATE/retrieve A NEW
TABLE WITH FIELDS;;;;

(fname, lname,email, userid,examid, examname,categoryname)

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by mschroeder
0

User(fname, lname,email and userid ------primary key{userid} )

Exam( examid, examname,categoriid-------primary Key{examid})

Exam_user(examid, userid------

Exam_category(categoryid, categoryname----prmary key{categoryid})

you can write:

select u.fname,u.lname,u.email,c.categoryname,e.examname from user as u,exam as e,exam user as eu,category as c where u.userid=eu.userid and eu.examid=e.examid and e.categoryid=c.categoryid;

the above is vary basic query, try inner joins to be more specific..
read joins tutorial in google..

0

It doesn't look like you posted your entire table structures, hence there is no reasonable way to know where Exam_category.categoryid joins to the three other tables.

I'd also like to know the conditions of your joins.
e.g.
Can a user take the same exam more than once. ( Fail, Fail, Pass etc.)
Can an exam have more than one category and if so how does this connection between exams and categories get made.

These questions will drastically affect the kind of joins that should be used.

Please post your entire sql structure for your tables.

This topic has been dead for over six months. 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.