mysql高级函数

money, if(money is null, '呵呵', '哈哈') 备注 from account;:if语句 6.case条件语句 1.create table copy like user;:复制user表(只复制表的字段) 2.create table copy select * from user;:复制user表(字段数据一起复制) 3.create table copy select username,age from u...
mysql高级函数
1.select concat(name, money) from account; :拼接字段 2.select length(name) from account;:查询字节长度(根据编码集utf-8,一个汉字占三个字节) 3.select ifnull(money, 10) from account;:如果money为null,显示10 4.select round(money,1) from account;:保留一位小数四舍五入 5.select floor(money) from account; :向下取整 6.select ceil(money) from account;:向上取整 7.select truncate(money, 1) from account;:截断(截取一位小数) 8.select mod (10, 3);:取余(相当于select 10%3;) 9.select upper(name) from account; :将名字变成大写 10.select lower(name) from account;:将名字变成小写 11.select substring(name, 1) from account;:截取名字下标从1开始的所有字段(注意:mysql的下标都是从1开始) 12.select substring(name, 1, 4) from account;:截取名字下标从1开始,长度为4的字段 13.select now();:返回当前系统的日期和时间 14.select curdate();:返回当前系统的日期 15.select curtime();:返回当前系统的时间 16.select date_format(now(), '%Y年%m月%d日') as '当前时间';:将时间转换成字符串 17.select count(name) from account;:计算name的个数(忽略null) 18.select count( ) from account;:计算个数(不忽略null,类似:select count(1) from account;) 19.select lpad(name, 10, ' '), money from account;:指定字段在左边填充到指定长度(rpad:右边填充) 20.select replace(name, 'an', '*'), money from account;:替换指定字段 21.select * from user limit 0,5;:查询前5条数据(下标0开始,数量:(page - 1) * size, size) 22.select * from boy union select * from girl;:两个结果合成一个(会自动去重,不去重用:union all)
1.select sum(money) from account;:求和(忽略null,null和任何值相加都为null) 2.select sum(money) from account;:求平均数(忽略null) 3.select max(money) from account;:求最大值(忽略null) 4.select min(money) from account;:求最小值(忽略null) 5.select name, money, if(money is null, '呵呵', '哈哈') 备注 from account;:if语句 6.case条件语句
1.create table copy like user;:复制user表(只复制表的字段) 2.create table copy select * from user;:复制user表(字段数据一起复制) 3.create table copy select username,age from user;:复制user表(复制指定的字段,数据一起复制) 4.create table copy select username,age from user where 0;:复制user表(复制指定的字段,数据不复制) 5.alter table 表名 add|drop|modify|change column 列名【列类型 约束】;:修改表
1.等值连接:select s.studen, t.teacher from study s, teacher t where s.t_id = t.id;(求交集部分)
2022-06-02
mengvlog 阅读 880 次 更新于 2025-09-09 16:14:18 我来答关注问题0
  •  文暄生活科普 MySQL优化查询6:高级函数exists;rollup;cube;field等 | 数据分析笔记

    本文探讨了MySQL中的几种高级查询函数,包括exists, not exists, rollup, cube, field以及相关聚合操作。首先,exists和not exists用于替代子查询,exists返回boolean值,有效利用索引,提高了查询效率,而not exists则筛选出不存在条件的记录。在使用exists时,注意其where子句与from子句的表关联至关重要。rol...

  • 1.select concat(name, money) from account; :拼接字段 2.select length(name) from account;:查询字节长度(根据编码集utf-8,一个汉字占三个字节) 3.select ifnull(money, 10) from account;:如果money为null,显示10 4.select round(money,1) from account;:保留一位小数四舍...

  • MySQL的trim函数最基本的用途是去除字符串首尾的空格。这在数据处理中非常有用,尤其是当从各种来源获取的数据可能包含不必要的空格时。例如,`TRIM`将返回`'Hello World'`,即去除了首尾的空格。2. 高级用法:除了去除空格,trim函数还可以用于去除字符串两侧的特定字符。除了空格之外,可以指定其他任何字...

  •  赛玖久生活日记 【6】mysql函数

    ABS(X)功能:返回 X 的绝对值。示例:ABS(-5) 返回 5,ABS(3.14) 返回 3.14。注意:对于小数,ABS 函数也会返回其绝对值,并保持小数部分不变。SQRT(X)功能:返回 X 的平方根。示例:SQRT(16) 返回 4,SQRT(2.5) 返回 1.58113883008419(近似值)。注意:如果 X 是负数,则 SQRT 函数...

  •  翡希信息咨询 MySQL函数加密函数

    MySQL提供了一系列加密函数,以确保数据的安全性。以下是MySQL中常用的加密函数:AES加密函数:AES_ENCRYPT:用于高级加密标准加密。接受一个字符串和一个密钥,返回加密后的字符串。AES加密可以使用128位或256位的密钥。AES_DECRYPT:用于AES解密。接受一个加密字符串和一个密钥,返回解密后的原始字符串。

檬味博客在线解答立即免费咨询

mySQL相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部