I have two tables: USER and SUBJECTS
USER table
SUBJECT table
SUBJECT1, SUBJECT2, SUBJECT3 from table USER are foreign keys to column ID in table SUBJECT.
I'm trying to write an SQL query that returns all columns from the first table with the referenced values by the foreign keys to show that one user (teacher) can teach three subjects at a time. I want in the result to get the values from the second table, like this:
| ID | NAME | AGE | ADDRESS | SUBJECT1 | SUBJECT2 | SUBJECT3 |
+----+-------+-----+---------+----------+----------+----------+
| 1 | John | 30 | London | Math | English | Sports |
| 2 | Marry | 40 | London | English | Sports | Biology |
| 3 | Tom | 35 | Paris | English | Sports | Russian |