我如何安排我使用组连接的数据的输出?

发布于 2024-10-19 06:30:30 字数 615 浏览 6 评论 0原文

我想按降序排列数据的输出 这是我的代码:

$result3 = mysql_query("SELECT grade1.Semester, curriculum.SCode, curriculum.SDesc, curriculum.Lec, curriculum.Lab, curriculum.Units, curriculum.Prereq, GROUP_CONCAT(grade1.Grade1) as Grade1 , students.StudNo, grade1.YearLevel
FROM students 
    INNER JOIN grade1 
        ON students.StudNo = grade1.G1StudNo 
    INNER JOIN curriculum
        ON curriculum.SCode = grade1.G1SCode
         WHERE StudNo = '$id'
GROUP BY StudNo,SCode ")

这是输出: 在此处输入图像描述

我想要发生的是 5,5,1.. 当我使用 group_concat 时我该怎么做?

i want to arrange the output of my data in descending Here is my code:

$result3 = mysql_query("SELECT grade1.Semester, curriculum.SCode, curriculum.SDesc, curriculum.Lec, curriculum.Lab, curriculum.Units, curriculum.Prereq, GROUP_CONCAT(grade1.Grade1) as Grade1 , students.StudNo, grade1.YearLevel
FROM students 
    INNER JOIN grade1 
        ON students.StudNo = grade1.G1StudNo 
    INNER JOIN curriculum
        ON curriculum.SCode = grade1.G1SCode
         WHERE StudNo = '$id'
GROUP BY StudNo,SCode ")

Here is the output:
enter image description here.

What i want to happen is 5,5,1.. how can i do that when i am using group_concat?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

葬花如无物 2024-10-26 06:30:30

查看 GROUP_CONCAT

GROUP_CONCAT(grade1.Grade1 ORDER BY grade1.Grade1 DESC)

Check out the docs on GROUP_CONCAT:

GROUP_CONCAT(grade1.Grade1 ORDER BY grade1.Grade1 DESC)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文