我无法显示JOIN查询的结果(I Can't display the Results of a JOIN query)

编程入门 行业动态 更新时间:2024-10-28 01:18:51
我无法显示JOIN查询的结果(I Can't display the Results of a JOIN query)

(在php中使用mysql)

嗨,我似乎无法通过谷歌或在这个网站上找到答案,所以非常感谢帮助。 我正在尝试加入2个桌子,一起显示学生的名字,然后按字母顺序排序,我还没有得到帮助,如何做到这一点也赞赏:D。 所需的所有信息都在这里

id设置为INT NOT NULL AUTO_INCREMENT并且是StudentID设置为INT的PRIMARY KEY ,Name设置为VARCHAR(30) ,age也设置为INT 。

我的问题是,为什么以下的PHP脚本没有显示任何结果? 除了桌子? 我正在使用wamp。

(Using mysql in php)

Hi people i cant seem to find the answer through google or on this site so help is much appreciated. I'm trying to join 2 tables together displaying JUST the name of students, then to order it alphabetically which i havent gotten into yet help on how to do that is also appreciated :D. All info needed is here

the id is set to INT NOT NULL AUTO_INCREMENT and is the PRIMARY KEY the StudentID is set to INT the Name is set to VARCHAR(30) and the age is set to an INT as well.

My question is, why is the following php script not displaying any results? besides the table? I am using wamp.

最满意答案

您需要UNION两个结果并在其上应用ORDER ,例如:

SELECT Name FROM( SELECT Name FROM Group1 UNION SELECT Name FROM Group 2 ) a ORDER BY a.Name;

You need to UNION both the results and apply ORDER on it, e.g.:

SELECT Name FROM( SELECT Name FROM Group1 UNION SELECT Name FROM Group 2 ) a ORDER BY a.Name;

更多推荐

本文发布于:2023-07-14 13:42:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1104801.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:display   JOIN   query   Results

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!