SELECT S1.Sname,S1.sex FROM student AS S1, student AS S2 WHERE S1.age = S2.age AND S1.Sname <> S2.Sname GROUP BY S1.Sname ORDER BY S1.age
学生表中 求出 年龄相同的同学 列出同学的名称和年龄
-- 学生表 CREATE TABLE student (Sno varchar(20) NOT NULL, Sname varchar(20) NOT NULL, sex varchar(20) NOT NULL, age INT NOT NULL, dept varchar(20) NOT NULL, PRIMARY KEY (Sno) ); INSERT INTO student VALUES ('9512101','李勇','男',19,'计算机系'); INSERT INTO student VALUES ('9512102','刘晨','男',20,'计算机系'); INSERT INTO student VALUES ('9512103','王敏','女',20,'计算机系'); INSERT INTO student VALUES ('9521101','张立','男',22,'信息系'); INSERT INTO student VALUES ('9521102','吴宾','女',21,'信息系'); INSERT INTO student VALUES ('9521103','张海','男',20,'信息系'); INSERT INTO student VALUES ('9531101','钱小力','女',18,'数学系'); INSERT INTO student VALUES ('9531102','王大力','男',19,'数学系');
标签:INSERT,20,同一个,INTO,获取,VALUES,student,表中,S1 From: https://www.cnblogs.com/abcdefghi123/p/18001781