【多选题】在MySQL中,学生表Students中包含学号sid(主键)、姓名sname。现在查询所有有重名的学生姓名,以下语句正确的是()。
A. select sname from students group by sid having count(sid)>1; B. select sname from students group by sname having count(sid)>1; C. select distinct a.sname from students A, students B where A.sname=B.sname; D. select distinct a.sname from students A, students B where A.sname=B.sname and A.sid !=B.sid;
A. select sname from students group by sid having count(sid)>1; B. select sname from students group by sname having count(sid)>1; C. select distinct a.sname from students A, students B where A.sname=B.sname; D. select distinct a.sname from students A, students B where A.sname=B.sname and A.sid !=B.sid;
举一反三
- 在MySQL中,查看学生表Students表中的姓名Sname属性的SQL语句表达正确的是( )。 A: SELECT * FROM Students B: SELECT * FROM Students WHERE Sname="" C: SELECT Sname FROM Students D: SELECT Sname FROM Students WHERE Sname=""
- 在学生关系student(sid,sname……)中,student的属性分别表示学号和姓名,若要查询学号为19170201的学生姓名,下列SQL语句正确的是( )。Ⅰ.SELECT sname FROM student WHERE sid LIKE '19170201'Ⅱ.SELECT sname FROM student WHERE sid LIKE= '19170201'Ⅲ.SELECT sname FROM student WHERE sid='19170201' A: Ⅰ、Ⅱ B: Ⅰ、Ⅲ C: Ⅱ、Ⅲ D: Ⅰ、Ⅱ、Ⅲ
- 查询学生的学号,姓名,选修课程号和课程成绩 A: select sid,sname,cid,grade from student,sc where student.sid=sc.sid B: select * from student,sc where student.sid=sc.sid C: select sid,sname,cid,cname from student,course D: select sid,sname,cid,cname from student,sc
- 假定有学生关系S,结构为S(SID, SNAME, AGE),其中SID为学号,SNAME为姓名,AGE为年龄。查询所有比“李军”年龄大的学生的姓名、年龄,正确的SQL语句是( )。 A: SELECT SNAME, AGE FROM S WHERE AGE > ( SELECT AGE FROM S WHERE SNAME = '李军' ) B: SELECT SNAME, AGE FROM S WHERE AGE >( SNAME= '李军' ) C: SELECT SNAME, AGE FROM S WHERE AGE > ( SELECT AGE WHERE SNAME='李军' ) D: SELECT SNAME, AGE FROM S WHERE AGE>李军.AGE
- 以下创建视图的语句中,正确的是 A: CREATE st_view AS SELECT sid,sname,ssex FROM stu B: CREATE VIEW st_view SELECT sid,sname,ssex FROM stu C: CREATE VIEW st_view AS sid,sname,ssex FROM stu D: CREATE VIEW st_view AS SELECT sid,sname,ssex FROM stu