Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2016-06-07 17:38:10
Original
873 people have browsed it

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)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template