3

SQL学习--单表查询

 2 years ago
source link: https://fann.im/blog/2008/04/14/sql-study-select-1/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

SQL学习--单表查询

Apr 14, 2008

指定列:select Sno,Sname from Student;

查询经过计算的值:select Sname, 'year of birth:', 2008-Sage, Sdept from student;

去除取值重复的行:select distinct Sno from student;

足条件的元组:select Sname,Sage from Student where Sdept ='CS' AND Sage<=19;

确定范围,集合 select Sname from Student where Sage BETWEEN 18 AND 20;

匹配查询 select * from Student where Sno LIKE '100%';

Order By子句 select Sno,Grade from SC where Cno ='2' ORDER BY Grade DESC; //DESC是降序,缺省为升序

聚集函数:select COUNT(Sno) from Student;

Group By子句:select Cno,COUNT(Cno) from SC GROUP BY Cno;

Was this page helpful?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK