mysql 经常使用几个函数简单实例演示

instr()/lower()/replace()/substr()/las_day:ide

-- 1.用 instr() 函数查找w在hello world短语中出现的字符位置 **
select instr('hello word','w'); 函数

-- 2.用 lower() 函数将HELLO转换为小写,用 upper() 函数将world转换为大写,并用 concat() 函数将两部分链接在一块儿 *
select concat(lower('HELLO') ,upper('Word')) ; orm

-- 3.用 replace() 函数将 hello earth 短语中的 earth 替换为 world *
select replace('hello earth' ,'earth' ,'world');it

-- 4.用 substr() 函数提取 hello world 短语中 llo w 部分的内容 **
select substr('hello world',3,5);ast

-- 5.用last_day函数返回当前月份的最后一天的日期(当前日期是变量now) **
select last_day(now());form

-- 6.用date_format将文本'2019-01-01'转换为正确的日期型日期 ***
select date_format('2019-01-01','%Y-%m-%d'); class

-- 7.用cast函数将emp表中的empno数字转换为文本型 ***
select cast(empno as char(4)) from emp;变量

文章出处https://zhuanlan.zhihu.com/p/73199108date