I have two tables ticket
and attr
. Table ticket
has ticked_id
field and several other fields. Table attr
has
You use table aliases
eg:
Select
ticket.ticket_id,
a1.attr_val as attr_val1,
a2.attr_val as attr_val2,
a3.attr_val as attr_val3
from ticket
left join (select * from attr where attr_type=1) a1 on ticket.ticket_id=a1.ticket_id
left join (select * from attr where attr_type=2) a2 on ticket.ticket_id=a2.ticket_id
left join (select * from attr where attr_type=3) a3 on ticket.ticket_id=a3.ticket_id