前沿小补充

``````SELECT Sno,AVG(Grade)
FROM SC
GROUP BY Sno;
SELECT * FROM SC;
``````

``````SELECT Sno,AVG(Grade)
FROM SC
GROUP BY Sno
SELECT * FROM SC;
``````

HAVING短语作用于组，从中选择满足条件的组

等值与非等值连接查询

``````[<表名1>.]<列名1><比较运算符>[<表名2>.]<列名2>
``````

``````SELECT Student.*,SC.*
FROM Student,SC
WHERE Student.Sno=SC.Sno;
SELECT * FROM SC;
SELECT * FROM Student;
``````

``````SELECT Student.*,SC.*
FROM Student,SC

SELECT * FROM SC;
SELECT * FROM Student;
``````

``````SELECT Student.Sno,Sname,Ssex,Sage,Sdept,Cno,Grade
FROM Student,SC
WHERE Student.Sno=SC.Sno;
SELECT * FROM SC;
SELECT * FROM Student;
``````

``````SELECT Student.Sno,Sname
FROM Student,SC
WHERE Student.Sno=SC.Sno
AND SC.Cno='2'
SELECT * FROM SC;
SELECT * FROM Student;
``````

自身连接

``````SELECT FIRST.Cno,SECOND.Cpno
FROM Course FIRST,Course SECOND
WHERE FIRST.Cpno=SECOND.Cno;
SELECT * FROM Course;
``````

外连接

``````SELECT *
FROM Student LEFT OUTER JOIN SC ON(Student.Sno=SC.Sno);
--SELECT * FROM Course;
SELECT * FROM SC;
SELECT * FROM Student;
``````

多表连接

``````SELECT Student.Sno,Sname,Cname,Grade
FROM Student,SC,Course
WHERE Student.Sno=SC.Sno AND SC.Cno=Course.Cno;
SELECT * FROM Course;
SELECT * FROM SC;
SELECT * FROM Student;
``````

``````SELECT *
FROM Student,SC,Course
WHERE Student.Sno=SC.Sno AND SC.Cno=Course.Cno;
``````