avg() |
返回数值列的平均值 |
select avg(column_name ) from table_name |
between() |
选取介于两个 值之间的数据范围内的,值可以是数值文本或者日期 |
select column_name from table_name where between value1 and value1 |
ceiling() |
向上舍入 为指定小数位数 |
ceiling(numerical ,decimal place ) |
concat |
将多个字符串 连接成一个字符串 |
concat(str1 , str2 ,…) |
concat_ws |
和concat 一样,将多个字符串 连接成一个字符串 ,但是可以指定分隔符 |
concat_ws(separator , str1 , str2 , …) |
Count(column_name) |
返回指定列 的值的数目 ,NULL 值除外 |
select Count(column_name ) from table_name |
Count(*) |
返回表中的记录数 ,包括 NULL 值 |
select Count(*) from table_name |
Count(distict column_name) |
返回指定列的不同值 的数目 |
select Count(distict column_name ) from table_name |
cast() |
将某种数据类型 的表达式 显式转换为另一种数据类型 |
select cast(expression as data_type ) |
floor() |
向下舍入 为指定小数位数 |
floor(numerical ,decimal place ) |
format() |
对字段 的显示 进行格式化 |
select format(column_name ,format ) from table_name |
group by |
根据一个或多个列对 结果集进行分组 |
select group_concat(column_name ,column_name ) from table_name group by table_name |
where |
提取那些满足指定条件 的记录 |
select column_name from table_name where column_name operator value |
if() |
条件判断 语句 |
if(condition ,Tlue ,False ) |
limit |
用于限制 查询结果返回的数量 |
select * from table_name limit index ,quantity |
lengh |
获取字符串长度 |
select lengh() |
lcase() |
把字段 的值转换为小写 |
select lcase(column_name ) from table_name |
mid() |
从文本字段 中提取字符 |
select mid(column_name ,start ,[length ]) from table_name |
min() |
返回指定列的最小值 |
select min(column_name ) from table_name |
max() |
返回指定列的最大值 |
select max(column_name ) from table_name |
round() |
四舍五入 把原值转化为指定小数位数 |
round(numerical ,decimal place ) |
Rand() |
随机函数 随机出0到1 的一个数 |
select Rand() |
select |
从数据库 中选取数据 |
select 数据名 from 数据库名 |
select disstinct |
用于返回唯一不同的值 |
select disstinct column_name ,column_name from table_name |
show |
列出数据库系统 中所有的数据库 |
show databases or tables |
substr |
截取字符串的内容 |
substr(str ,start ,end ) |
Sum() |
返回数值列的总数 |
select Sum(column_name ) from table_name |
Sleep() |
休眠 |
select slepp(time ) |
top() |
用于规定 要返回的记录的数目 |
select top (numerical * ) or (numerical percent) from name |
use |
改变当前操作数据库 |
use 数据库名 |
ucase() |
把字段 的值转换为大写 |
select ucase(column_name ) from table_name |
union |
合并两个 或多个 SELECT 语句 的结果 |
select column_name ,… from table_name union select ..... |
union all |
在union基础上可以允许选取重复的值 |
select column_name ,… from table_name union all select ..... |