select c1.*, c2.*, c3.* from (select car_id from table group by car_id) as c
left join table as c1 on c1.car_id=c.car_id and c1.tpye_insid = 1
left join table as c2 on c2.car_id=c.car_id and c2.tpye_insid = 2
left join table as c3 on c3.car_id=c.car_id and c3.type_insid = 3
select c1.*, c2.*, c3.* from (select car_id from tbcar group by car_id) as c
left join tbinsurance as c1 on c1.car_id=c.car_id and c1.tpye_insid = 1
left join tbinsurance as c2 on c2.car_id=c.car_id and c2.tpye_insid = 2
left join tbinsurance as c3 on c3.car_id=c.car_id and c3.type_insid = 3
มัน error Unknown column 'c1.tpye_insid' in 'on clause'
คับ
select c1.*, c2.*, c3.* from (select car_id from table group by car_id) as c
left join table as c1 on c1.car_id=c.car_id and c1.tpye_insid = 1
left join table as c2 on c2.car_id=c.car_id and c2.tpye_insid = 2
left join table as c3 on c3.car_id=c.car_id and c3.type_insid = 3
ปล
c1. c2. c3 มาจากชื่อเล่น ของตารางครับ เมื่อ select มาจากชื่อเดียวกัน ก็ต้องเปลี่ยนชื่อครับ ในการ เรียกใช้ไม่ซ้ำกัน
left join table as c1 on c1.car_id=c.car_id and c1.type_insid = 1
left join table as c2 on c2.car_id=c.car_id and c2.type_insid = 2
left join table as c3 on c3.car_id=c.car_id and c3.type_insid = 3