I have a very confusing database with a table that holds two values I need in a separate table. Here is my issue:
Table1
- id
Table2
- id
- table1_id
- tabl
select t1.id as table1_id,
t2.id as table2_id,
t2.table3_id_1,
t2.table3_id_2,
t3_1.value as X,
t3_2.value as Y
from Table1 t1
inner join Table2 t2 on t1.id = t2.table1_id
inner join Table3 t3_1 on t2.table3_id_1 = t3_1.id
inner join Table3 t3_2 on t2.table3_id_2 = t3_2.id
where t3_1.value = 'some_value'
or t3_2.value = 'some_other_value'