数据库视频---数据查询和管理

简单的SELECT语句:

SELECT[ALL|DISTINCT]select list
[INTO new_table]
FROM table_source
[WHERE search_conditions]
[GROUP BY group_by_expression]              '分组
[HAVING search_conditions]                  'having子句
[ORDER BY order_expression[ASC|DESC]]       '排序

设置查询语句

select * from...where...and ..

排序

select * from result_Info where student_ID=1 
order by...DESC    '降序排序
order by...ASC     '增序排序

使用函数

select max(result)from  result_Info  where... =...and ...=...   '最大(最小min)
select avg(result)from  result_Info  where... =...and...=...    '平均数
select sum(result)from  result_Info  where... =...and ...=...   '求和

使用HAVING子句
用在查询语句下边
INSERT… SELECT语句

INSERT table_name[column_list]
SELECT column_list
FROM table_list
WHERE search_condirions

SELECT…INTO语句

SELECT 
INTO new table 
FROM {},[,...n]
WHERE 

UPDATE语句

UPDATE [TOP] {table_name|view_name}
SET
{column name={expression|DEFAUIT|NULL}|@variable=expression}[,...n]
WHERE {search_conditions}

DELETE语句

DELETE FROM 
[WHERE ]
 
  

TOP关键字和表达式

[
TOP (expression)[PERCENT]
[WITH TIES]
]

用在增删改查四种语句中,在关键字后用TOP关键字
expression具体数值
PERCENT百分比
COMPUTE子句

[
COMPUTE
{{AVG|COUNT|MAX|MIN|STDEV|STDEVP|VAR|VARP|SUM}
(expression)}[,...n]
[BY expression[,...n]
]

在where子句中使用运算符
在子句中可以使用:and or + - * % in 等等,不仅仅是只能使用等于

你可能感兴趣的:(数据库视频---数据查询和管理)