Table name-userdb
id | name | value
1 | fname | anand
1 | lname | kumar
1 |city | bangalore
2 |fname |mahesh
2 |lname |sahoo
2 |city |manglore
3 |fname |anil
3 |lname |singh
3 |city |balasore
我需要显示
fname | lname | city
anand | kumar | bangalore
mahesh | sahoo | manglore
anil |singh |balasore
为此请给我mysql查询
答案 0 :(得分:0)
mmm .. EAVS ......除了实际实现设计的明显建议之外,你可以实现你想要的:
Select Min( Case When name = 'fname' Then value End ) As fname
, Min( Case When name = 'lname' Then value End ) As lname
, Min( Case When name = 'city' Then value End ) As city
From MyTable
Group By Id