有两个表a,b
a表结构
testid int(11)
b表结构
b_id int(11)
testid int(11)
status int(2)
note varchar(50)
a表和b表通过testid关联,我需要取出 a表的testid和b表的note,其中根据b表status的不同note分别取别名为note1,note2,……note20,status一共有20个状态,a和b之间的连接可能为inner join 也可能为left join 我现在的sql取法是(以left join为例):
SELECT a.testid,b1.note note1,b2.note note2,b3.note note3,……
FROM a 
LEFT JOIN b b1 ON a.testid=b1.testid and b1.status=1
LEFT JOIN b b2 ON a.testid=b2.testid and b2.status=2
LEFT JOIN b b3 ON a.testid=b3.testid and b3.status=3
……
这样写sql比较慢,请问还有别的做法能取出note1,note2,note3……吗?谢谢!