我有db表用户,该表有5行
id username attr value
1 ahmed text1 ....
2 ahmed text2 ....
3 ahmed text3 ....
....
我的查询是
select
u1.value as `val1`,
u2.`value` as `val2` ,
u2.`value` as `val3`
FROM `users`
`u1`
LEFT JOIN `users` `u2` ON (`u2`.`username` = `u1`.`username` AND `u2`.`attr` = 'text2')
LEFT JOIN `users` `u3` ON (`u3`.`username` = `u1`.`username` AND `u3`.`attr` = 'text3')
WHERE `u1`.`attr` = 'text1'
我希望任何想法都能使行速更快,对不起我的英语