Hi Guys,
I need some help with a couple of tables and a query. I am building a test generator for our teachers here (we are a school) and I have set up my tables as follows:
QCat:
QCatID - PK
QCat
QTypes: (Question Types eg, True/False, Multi Choice)
QTypeID - PK
QType
Questions:
QID - PK
Question
QTypeID - FK
CatID - FK
What I would like out of my query, is a join and then to receive the Categories Name and the Number of questions for each Question Type under that (if any):
Eg:
Maths
- T/F - 4
- M/C - 2
English
- M/C - 5
Here is the join and the query that doesn't work. I'm sure I have done it wrong but I don't understand it enough to fix it. This only gives me one line of cells. Can someone please help?
SELECT QCat.QCat, QType.QTypeID
FROM QType RIGHT JOIN (Cat LEFT JOIN Questions ON Cat.QCatID = Questions.QCat) ON QType.QTypeID = Questions.QType
GROUP BY qcatid.qcatid, QType.QTypeID
ORDER BY QCat.QCat, QType.QTypeID;
Cheers
Batty
I need some help with a couple of tables and a query. I am building a test generator for our teachers here (we are a school) and I have set up my tables as follows:
QCat:
QCatID - PK
QCat
QTypes: (Question Types eg, True/False, Multi Choice)
QTypeID - PK
QType
Questions:
QID - PK
Question
QTypeID - FK
CatID - FK
What I would like out of my query, is a join and then to receive the Categories Name and the Number of questions for each Question Type under that (if any):
Eg:
Maths
- T/F - 4
- M/C - 2
English
- M/C - 5
Here is the join and the query that doesn't work. I'm sure I have done it wrong but I don't understand it enough to fix it. This only gives me one line of cells. Can someone please help?
SELECT QCat.QCat, QType.QTypeID
FROM QType RIGHT JOIN (Cat LEFT JOIN Questions ON Cat.QCatID = Questions.QCat) ON QType.QTypeID = Questions.QType
GROUP BY qcatid.qcatid, QType.QTypeID
ORDER BY QCat.QCat, QType.QTypeID;
Cheers
Batty