From aa9441a4e65b9256cc77e9b863e00d48679e6a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B7=AF=E4=BA=BA?= <8737932+passers-bye@user.noreply.gitee.com> Date: Thu, 2 Sep 2021 11:56:23 +0000 Subject: [PATCH] =?UTF-8?q?=E8=B5=B5=E5=90=91=E9=98=B3=E4=BD=9C=E4=B8=9A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\350\265\265\345\220\221\351\230\263.sql" | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 "\350\265\265\345\220\221\351\230\263.sql" diff --git "a/\350\265\265\345\220\221\351\230\263.sql" "b/\350\265\265\345\220\221\351\230\263.sql" new file mode 100644 index 0000000..75175fb --- /dev/null +++ "b/\350\265\265\345\220\221\351\230\263.sql" @@ -0,0 +1,64 @@ +use sllllllll; + +create TABLE Student +( +stuid int PRIMARY KEY, +stuName VARCHAR(20) not null, +stusj datetime not null, +stucj datetime +); + +SELECT name,LENGTH(name) from user; +select LENGTH('123ab韩国c'),OCTET_LENGTH('123ab美国c') + +select CHAR_LENGTH('123ab法国c') + +-- 替换 +select replace( '123425','2','asd') + +select INSERT('12342562789',2,3,'ABC') + +-- 截取 +SELECT select('123488',3) + +SELECT RIGHT('66666',3) + +select SUBSTRing('123456789',-5,3) + +-- 拼接 +select concat('wer','bbb','8888') + +-- 逆序 +select REVERSE('123444') + +-- 大小写转换 +select UPPER('美国eeeEFG123') + +select LOWER('法国G123') + +-- 去空格 +select TRIM(' 13 2 '); + +select LTRIM(' 3 13 '); + +select RTRIM(' 14 5 '); + +select REPLACE(' 15 6 ',' ',''); + +-- 时间函数 +select NOW() + +-- 流程控制 +-- IF 三目运算符 +select *,IF(stuid>=3,'小狗','小猫')改名 from Student; + +select *, +( + CASE +WHEN stuid>=3 THEN + '小狗' +ELSE + '小猫' +END +)改名 + from Student; -- Gitee