這裏是我的問題的一個示例表:要在多個列中檢索多行值轉換爲單列單個表
數據庫:MySQL 5.1中
表名:教育
id edutype university subjects yearofpass percentmarks
200 1 CBSE Maths,Science,English,Hindi 2002 78.00
200 2 CBSE Maths,Physics,Chem,Biology 2004 68.00
200 3 WBUT Computer Science Engineering 2008 87.00
100 1 ICSE Maths,Science,English,Hindi 2001 72.00
100 2 CBSE Maths,Physics,Chem,Biology 2003 65.00
100 3 NIT Electronics Engineering 2008 75.00
300 1 CBSE Maths,Science,English,Hindi 2003 65.00
300 2 CBSE Maths,Physics,Chem,Biology 2005 63.00
300 3 VIT Metallurgy Engineering 2009 79.00
現在我想運行一個SQL查詢,它將輸出以下格式的結果:
id uvr1 sub1 yop1 pcm1 uvr2 sub2 yop2 pcm2 uvr3 sub3 yop3 pcm3
200 CBSE Maths,Science,English,Hindi 2002 78.00 CBSE Maths,Physics,Chem,Biology 2004 68.00 WBUT Computer Science Engineering 2008 87.00
100 ICSE Maths,Science,English,Hindi 2001 72.00 CBSE Maths,Physics,Chem,Biology 2003 65.00 NIT Electronics Engineering 2008 75.00
300 CBSE Maths,Science,English,Hindi 2003 65.00 CBSE Maths,Physics,Chem,Biology 2005 63.00 VIT Metallurgy Engineering 2009 79.00
請分享,如果你有一個這是很好的方法,需要你的幫助。
在此先感謝
這種操作確實屬於您的應用程序的表示層。 – eggyal 2013-04-30 07:51:38