次のようなクエリを使用できます:
SELECT subjectcode.Year1, subjectcode.Year2,
subjectcode.Subjectcode, subjectcode.Subjectname,
subjectcode.Theory_Practical, q.fee
FROM subjectcode
INNER JOIN (
SELECT fees.Year1, fees.Year2, "Theory" As FeeType,
fees.Theoryfee As Fee
FROM fees
UNION ALL
SELECT fees.Year1, fees.Year2, "Practical" As FeeType,
fees.Practicalfee As Fee
FROM fees) AS q
ON (subjectcode.Theory_Practical = q.FeeType)
AND (subjectcode.Year2 = q.Year2)
AND (subjectcode.Year1 = q.Year1)
ただし、内部SQLによって返されるデータ、つまり理論と実際の料金の別の行に一致するように料金テーブルを再設計する方がはるかに良いでしょう。
Year1 Year2 FeeType Fee
2001 2003 Theory 440
2001 2003 Practical 320