From 316e721ac955722e5d66d4905cd7f916c5f40297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E5=BD=AC=E5=BD=AC?= <3204487492@qq.com> Date: Thu, 2 Sep 2021 09:41:26 +0000 Subject: [PATCH] zy --- "\346\233\271\345\275\254\345\275\254.sql" | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 "\346\233\271\345\275\254\345\275\254.sql" diff --git "a/\346\233\271\345\275\254\345\275\254.sql" "b/\346\233\271\345\275\254\345\275\254.sql" new file mode 100644 index 0000000..caad050 --- /dev/null +++ "b/\346\233\271\345\275\254\345\275\254.sql" @@ -0,0 +1,64 @@ +create database class; +use class; + +select LENGTH('123ab中国c'),OCTET_LENGTH('123ab中国c')--字符长度 + +select CHAR_LENGTH('123ab中国c')--字节长度 + + +select REPLACE('123456789','2','999')--把2替换成999 +select INSERT('123456789',2,3,'999')--把从2开始的3为数的替换成999 + + +select LEFT('123456789',3)--从左边截取3位数 +select RIGHT('123456789',3)--从右边截取3位数 +select SUBSTRING('123456789',-4,3)--从右边第5位截取3位数 + +select CONCAT('abc','123','中国')--拼接 + +select REVERSE('123456789')--逆序 + +select UPPER('中国abcEFG123')--小写转大写 +select LOWER('中国abcEFG123')--大写转小写 + +select TRIM(' 12 3 ');--去掉左边的空格 +select RTRIM(' 12 3 ');--去掉右边的空格 +select REPLACE(' 12 3 ',' ','');--去掉所有的空格 + + +select NOW()--获取当前时间日期 + +SELECT UNIX_TIMESTAMP('2021-09-02 15:13:28');--转化秒 +SELECT FROM_UNIXTIME(1630566808);--转化日期 + + +select *,if(money>=0,'正常','异常')资金状态 from user; + +select *,( +CASE + WHEN money>=0 THEN + '正常' + ELSE + '异常' +END + +)资金状态 +from user; + + +select *,( +CASE status + WHEN 1 THEN + '在线' + WHEN 2 THEN + '限制登入' + WHEN 4 THEN + '被删除' + ELSE + '未知状态' +END +)用户状态 + from user; + + +SELECT *, IFNULL(IDCODE,0)IDCODE from user; \ No newline at end of file -- Gitee