Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP MYSQL将统一值输出到同一个表列_Php_Mysql_Sql - Fatal编程技术网

PHP MYSQL将统一值输出到同一个表列

PHP MYSQL将统一值输出到同一个表列,php,mysql,sql,Php,Mysql,Sql,我的MySQL中有一个表,如下所示 ============================ id | courses | r_number ---------------------------- 1 | English | C/009 2 | Maths | C/009 3 | English | C/003 4 | Maths | C/002 ============================ 如何将其输出为下面的HTML表 ===

我的MySQL中有一个表,如下所示

============================
id  | courses   | r_number  
----------------------------
1   | English   | C/009
2   | Maths     | C/009
3   | English   | C/003
4   | Maths     | C/002
============================
如何将其输出为下面的HTML表

====================================
id  | courses           | r_number  
------------------------------------
1   | English, Maths    | C/009
2   | English           | C/003
3   | Maths             | C/002
====================================
我想知道为什么在您的示例中,
ID
与记录不匹配,为什么


我想知道为什么在您的示例中,
ID
与记录不匹配,为什么会这样?

第二个表是HTML表上的out。谢谢你的鼓励。我又回到正轨上了!第二个表是HTML表上的输出。谢谢你的鼓励。我又回到正轨上了!
SELECT  MIN(ID) ID,
        GROUP_CONCAT(Courses SEPARATOR ', ') Courses,
        r_Number
FROM    TableName
GROUP   BY r_Number
ORDER   BY ID