1, single-table queries
(1) student table query all students attribute information:
select * from student
(2) a query for all students of the school number and name:
select sno,sname from student
(3) may query attribute value calculated after the output:
the SELECT sname, 2019 - SAGE - query name and age from Student
(4) expression of target columns may further be a string constant
select sname,'Year of Birth:',birthday from student
(5) distanct keyword
--distinct: for removing duplicate tuples, written after select, before the list of attributes
- a select statement can only have one distinct
(6) null operation
--isnull (A, B): is determined whether A is null, if the B value is null taken, function, or take the A
--null still involved in all the calculation result is null
(7) Sort
--order by property name list: the query results sorted by property name, if you need to change the sort, after the attribute name, desc descending, asc ASC
- Use keyword asc / desc, if omitted, the default is ascending
- in sort when given in the order of attributes in the attribute list
the SELECT studentno, sname, Email - query each student's school number, name and Email, in descending order according to the number of classes, according to the same class enrollment results in descending order. from Student the Order by classno desc , Point desc