select id from tb1 inner join
(select a1 from tb2) a_1 on id=a_1.a1 inner join
(select a2 from tb2) a_2 on id=a_2.a2 inner join
(select a3 from tb2) a_3 on id=a_3.a3 inner join
(select a4 from tb2) a_4 on id=a_4.a4 inner join
(select a5 from tb2) a_5 on id=a_5.a5
ถ้า ผลลัพธ์ผิด ให้ลอง เปลี่ยนจาก id ในการ join ดูนะคะ
Code
select id from tb1 inner join
(select a1 from tb2) a_1 on id=a_1.a1 inner join
(select a2 from tb2) a_2 on a_1.a1=a_2.a2 inner join
(select a3 from tb2) a_3 on a_2.a2=a_3.a3 inner join
(select a4 from tb2) a_4 on a_3.a3=a_4.a4 inner join
(select a5 from tb2) a_5 on a_4.a4=a_5.a5