In SQl, we mainly have 3 ways to join two tables.
Nested loop (well, if one table has a small number of rows) Hash Join (Well, if both tables have very large rows, this makes expensive hash generation in memory) Merge Join (Good when we sorted the data to join).
From your question, it seems that you want to use Nested Loop.
Let's say t1 has 20 lines, t2 has 500 lines.
Now it will be like
t1 t2, t1.MainId = t2.MainId
t3.
, ..