gpt4 book ai didi

mysql - 从两个表中获取数据?

转载 作者:行者123 更新时间:2023-12-01 00:46:00 27 4
gpt4 key购买 nike

<分区>

我必须找出作为最高分学生姓名的输出?我的两张 table 都是-

CREATE TABLE student(Fields_ID INT, Name VARCHAR(20));
INSERT INTO student(Fields_ID,Name) VALUES(30,'JYOTI');
INSERT INTO student(Fields_ID,Name) VALUES(31,'KIRTI');
INSERT INTO student(Fields_ID,Name) VALUES(32,'YOGITA');
INSERT INTO student(Fields_ID,Name) VALUES(33,'RASHMI');
INSERT INTO student(Fields_ID,Name) VALUES(34,'NUPUR');
SELECT * FROM student;
CREATE TABLE Marks(Fields_ID INT, Student_ID INT NOT NULL,marks INT NOT NULL);
INSERT INTO Marks(Fields_ID,Student_ID,Marks) VALUES (30,40,100);
INSERT INTO Marks(Fields_ID,Student_ID,Marks) VALUES (31,41,88);
INSERT INTO Marks(Fields_ID,Student_ID,Marks) VALUES (32,42,72);
INSERT INTO Marks(Fields_ID,Student_ID,Marks) VALUES (33,43,33);
INSERT INTO Marks(Fields_ID,Student_ID,Marks) VALUES (34,44,15);
SELECT * FROM Marks;

我试图从下面的代码中返回所需的输出,但它并没有返回相同的结果。知道为什么它没有返回正确的值。我是 MySql 的初学者,所以我无法找出问题所在。

   SELECT student.name,Marks.marks
FROM student INNER JOIN Marks
ON student.Fields_ID=Marks.Fields_ID;

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com