我正在处理文件上传成功的文件上传项目。
现在我正在寻找显示我的上传表格,用于存储上传文件的详细信息,如:
+--------------------+--------------------+------------------+-----------+
| projectId | filename | projectDetails |ProjectName |
+--------------------+--------------------+------------------+------------+
| pid1 | admin.zip | This Is A Test |myProject |
| pid1 | admin1.zip | This Is A Test |myProject |
| pid2 | admin2.zip | This Is A Test2 |myProject2 |
| pid2 | admin3.zip | This Is A Test2 |myProject2 |
| pid1 | admin4.zip | This Is A Test |myProject |
+--------------------+--------------------+------------------+------------+
我可以知道我可以得到像
这样的输出 +--------------------+--------------------+------------------+-----------+
| projectId | filename | projectDetails |ProjectName |
+--------------------+--------------------+------------------+------------+
| pid1 | admin.zip | This Is A Test |myProject |
| | admin1.zip | | |
| | admin4.zip | | |
+--------------------+--------------------+------------------+------------+
答案 0 :(得分:-1)
使用此查询怎么样:
select projectId, GROUP_CONCAT(distinct filename) as filename, projectDetails, ProjectName
from yourtable
group by pid1