Thursday, February 24, 2011

SQL - Complicated Queries

The table structure is like this below:
1. teacher table:
   a. id
   b. name
2. subject table:
  a. id
  b. major
3. handler table: who teacher handle the major
  a. id
  b. tid   // teacher id
  c. sid   // subject id

The problem is how to get a display of the third table with naming by using just one select statement. The answer is below:
SELECT, s.major FROM teacher t, subject s, handler
WHERE handler.tid = AND handler.sid =

No comments:

Post a Comment