Select * from table_name
Select column_name_1,column_name_2 from table_name
Select * from student where 姓名=‘刘婷’and 所在班级=2
Select * from student where 成绩 between 90 and 100
Select * from student where 姓名 like ‘刘%’
Select * from student where 备注 is NOT NULL
Select TOP 5 * from student
Select column_name AS column_alias from table_name
Select * from student order by 成绩 DESC
Select * from student order by 成绩 ASC
Select SUM(成绩) 总成绩 from student
Select AVG(成绩) 平均成绩 from student
Select MAX(成绩) 最高分,MIN(成绩) 最低分 from student
Select COUNT(*) 总行数 from student
Select 所在班级,SUM(成绩) AS 总成绩 from student GROUP BY 所在班级
查询student表中每个班级的总成绩
Select 所在班级,SUM(成绩) AS 总成绩 from student GROUP BY 所在班级 HAVING SUM(成绩)>200
查询student表中总成绩大于200的班级
Select * into student_bak from student
将student表的数据插入到新表student_bak中
Select * into student_2 from student WHERE 所在班级=2
将student表中2班的学生信息保存到表student_2中
左连接(A表全部显示,B表显示同A里相同的部分)
Select A.name 姓名A,A.school 学校A,B.name 姓名B,job 职业B from A left join B on A.name=B.name
右连接(B表全部显示,A表显示同B里相同的部分)
Select A.name 姓名A,A.school 学校A,B.name 姓名B,job 职业B from A right join B on A.name=B.name
内连接(显示AB表姓名相同的部分)
Select A.name 姓名A,A.school 学校A,B.name 姓名B,job 职业B from A inner join B on A.name=B.name
外连接(显示AB表全部的信息,其他为NULL)
Select A.name 姓名A,A.school 学校A,B.name 姓名B,job 职业B from A full join B on A.name=B.name