how to join 3 relational tables
- by orioncabbar
Hello there,
how to join 3 relational tables with the structure:
t1 | id
t2 | id | rating
t3 | source_id | relation
t3 stores the data of a field which t1 and t2 uses both. so source_id field can be t1's id or t2's id.
input : t1 id
output : t2 rating
an example:
**t1**
id |
---------
42 |
**t2**
id | rating
-------------
37 | 9.2
**t3**
id | source_id
--------------
42 | 1
37 | 1
26 | 2
23 | 1
what i want is to get 9.2 output with 42 input.
can you do that in one sql query?