日期:2014-05-16 浏览次数:21082 次
<table width="418" border="1"> <tr> <td width="48">teacher </td> <td width="68">class_time</td> <td width="52">t900 </td> <td width="52">t930 </td> <td width="39">t100</td> <td width="36">t1030</td> <td width="41">t1100</td> </tr> <tr> <td>A </td> <td>2012-5-14 </td> <td>班级A</td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>A </td> <td>2012-5-14 </td> <td> </td> <td> </td> <td>班级B</td> <td> </td> <td> </td> </tr> <tr> <td>A </td> <td>2012-5-14 </td> <td> </td> <td> </td> <td> </td> <td> </td> <td>班级C</td> </tr> <tr> <td>B</td> <td>2012-5-14 </td> <td> </td> <td>班级D</td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>B</td> <td>2012-5-14 </td> <td> </td> <td> </td> <td> </td> <td>班级E</td> <td> </td> </tr> </table> <p>合并成</p> <table width="418" border="1"> <tr> <td width="48">teacher </td> <td width="68">class_time</td> <td width="52">t900 </td> <td width="52">t930 </td> <td width="39">t100</td> <td width="36">t1030</td> <td width="41">t1100</td> </tr> <tr> <td>A </td> <td>2012-5-14 </td> <td>班级A</td> <td> </td> <td>班级B</td> <td> </td> <td>班级C</td> </tr> <tr> <td>B</td> <td>2012-5-14 </td> <td> </td> <td>班级D</td> <td> </td> <td>班级E</td> <td> </td> </tr> </table>
select teacher,class_time,group_concat(t900 SEPARATOR ''),group_concat(t930 SEPARATOR ''),group_concat(t930 SEPARATOR ''),group_concat(t100 0SEPARATOR ''),group_concat(t1030 SEPARATOR ''),group_concat(t1100 SEPARATOR '') from tb group by teacher,class_time