Tuesday, 17 September 2013

Select a value in a first table according to another value of a second table (sql)

Select a value in a first table according to another value of a second
table (sql)

let me explain my situation, it really clearer than the title! I have two
tables. Let give a look here and than I will you explain what I would like
to do.
First table (lesson table)
+------------------+----------------+
| LessonCode | SubjectCode |
+------------------+----------------+
| 1 | 10 |
| 2 | 11 |
| 3 | 12 |
+------------------+----------------+
Second table (subject table)
+------------------+----------------+------------+
| subjectCode | SubjectName | teacherCode|
+------------------+----------------+------------+
| 10 | Maths | 15 |
| 11 | English | 20 |
| 12 | Greek | 30 |
+------------------+----------------+------------+
I would select from table lesson the subject that has teacherCode=20. It
is possible in one query?

No comments:

Post a Comment