SELECT语句的一般格式|数据库(3.2P)
程序员文章站
2022-05-08 11:21:15
...
1、
SELECT Sname FROM Student WHERE Sname LIKE '李%';
SELECT * FROM Course WHERE Cname LIKE '_\_系统' ESCAPE '\'
ESCAPE ''表示““为换码字符。
这样匹配串中紧跟在”“后面的字符”"不再具有通配符的含义,转换为普通字符“”
2、
3、
SELECT * FROM Student ORDER BY Sdept,Sage DESC;
4、
SELECT COUNT(*) ALL_S,COUNT(DISTINCT Sno) DIS_S FROM SC;
SELECT AVG(Grade) 平均分,MAX(Grade) 最高分,Min(Grade) 最低分 FROM SC WHERE Cno=2;
5、
SELECT Cno,COUNT(Sno) FROM SC GROUP BY Cno;
SELECT Sno COUNT(*) FROM SC WHERE GROUP BY Sno HAVING COUNT(*) > 2;
6、
SELECT Student.*,SC.* FROM Student,SC WHERE Student.Sno = SC.Sno
SELECT X.Cno,Y.Cpno FROM Course X,Course Y WHERE X.Cpno = Y.Cno;
SELECT X.Sno,Sname,SC.Cno,Grade FROM STUDENT X LEFT OUTER JOIN SC ON (X.Sno=SC.Sno);
SELECT X.Sno,Sname,SC.Cno,Grade FROM STUDENT X RIGHT OUTER JOIN SC ON (X.Sno=SC.Sno);
上一篇: 查看缓存文件内容,一般缓存文件写入是数据库的连接名称
下一篇: 关于民族的数据库表设计