mysql join same table multiple times group by

Solutions on MaxInterview for mysql join same table multiple times group by by the best coders in the world

showing results for - "mysql join same table multiple times group by"
Luka
28 Jan 2020
1SELECT 
2    ticket.ticket_id,  
3    a1.attr_val AS attr_val1,
4    a2.attr_val AS attr_val2,
5    a3.attr_val AS attr_val3
6FROM ticket
7    LEFT JOIN attr a1 ON ticket.ticket_id=a1.ticket_id AND a1.attr_type=1
8    LEFT JOIN attr a2 ON ticket.ticket_id=a2.ticket_id AND a2.attr_type=2
9    LEFT JOIN attr a3 ON ticket.ticket_id=a3.ticket_id AND a3.attr_type=3
10