Skip to content
Advertisement

SQL – Fetch associated data from multiple table

I have 4 tables. The table does not contain any foreign key reference

t1:

t2:

t3:

t4:

I need to get all associated data.

When I specify ‘a1’ I expect something as,

I used the following query,

This fetches no result as INNER JOIN t4 AS d ON d.id = c.id does not have matching value.

How to return the intermediate result? Is this query optimized (or) should I write separate queries to fetch this? How to achieve this?

Advertisement

Answer

Do you just want left joins?

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement