>  기사  >  데이터 베이스  >  数据库表查询高级 触发器游标等

数据库表查询高级 触发器游标等

WBOY
WBOY원래의
2016-06-07 17:38:10856검색

SQL语句的执行顺序 SELECT 语句的处理顺序。 1.FROM 2.ON 3.JOIN 4.WHERE 5.GROUP BY 6.WITH CUBE 或 WITH ROLLUP 7.HAVING 8.SELECT 9.DISTINCT 10.ORDER BY 11.TOP 类型转换函数和union CAST ( expression AS data_type) CONVERT ( data_type, expression,

SQL语句的执行顺序

  SELECT 语句的处理顺序。

1.FROM

2.ON

3.JOIN

4.WHERE

5.GROUP BY

6.WITH CUBE 或 WITH ROLLUP

7.HAVING

8.SELECT

9.DISTINCT

10.ORDER BY

11.TOP

  类型转换函数和union

CAST ( expression AS data_type)

CONVERT ( data_type, expression,[style])

Select ‘您的班级编号’+ 1 错误这里+是数学运算符

SELECT FIdNumber,

CAST(RIGHT(sNo,3) AS int) as 后三位的整数形式,

CAST(RIGHT(sNo,3) AS int)+1 as 后三位加1,

CONVERT(int,RIGHT(sNo,3))/2 as 后三位除以2

FROM student

select fname,LEN(FName) as '名字的长度' from MyStudent

--CAST ( 要转换的数据/字段AS 目标数据类型)

select

cast(ISNULL(fmath,0) as varchar(10))+

cast(ISNULL(fenglish,0) as varchar(10))

from MyStudent

select cast(1 as varchar(10))+cast(1 as varchar(10))

--CONVERT ( 目标数据类型, 待转的数据或字段)

select Convert(varchar(10),1)+ Convert(varchar(10),1)

select * from MyStudent

select Convert(varchar(10),fage)+fgender from MyStudent

select CONVERT(varchar(20), getdate(),23)

--union联合后会删除相同内容的行,union all不会

--union 1)列数相同 2)对应列的类型相同

select * from newStudent union all

select * from newStudent2

--显示班级的数学和英语成绩,,以及总成绩?

select fname,fmath,fenglish from newStudent

union all

select '总分:',sum(fmath),sum(fenglish) from newStudent

select 1,80,100 union all

select 1,80,100 union

select 3,50,59 union all

select 4,66,89 union

select 5,59,100

存储过程(procedure)

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.