1、返回字符串 ‘liuqudanxinzhaohanqing!’ 的字符数
2、返回字符串 ‘liuqudanxinzhaohanqing!’ 中 ‘zhao’的起始位置
3、在字符串 ‘liuqudanxinzhaohanqing!’ 中 ‘zhao’的后面插入’文天祥’
4、把字符串 ‘liuqudanxinzhaohanqing!’ 中 ‘zhao’ 截取出来
针对字符串 ‘有志者,事竟成,破釜沉舟,百二秦关终属楚。有心人,天不负,卧薪尝胆,三千越甲可吞吴。’
5、返回字符串 的字符数
6、把字符串 的逗号替换成空格
7、把字符串 的前十二个字符,提取出来
8、把所有学生名字拼接起来,用英文逗号分隔 。
9、4的10次方是多少 ?
10、8开平方是多少 ?
11、80度的余弦值是多少 ?
12、3.14 向上取整 。
12、截止 2021年03月20日 12:00:00 ,2021年已经过去多少时间 ?
14、获取 2021年12月20日 的下月第一天 和上月最后一天。 提示:多函数配合使用
-- 1、返回字符串 'liuqudanxinzhaohanqing!' 的字符数select char_length('liuqudanxinzhaohanqing!');select length(a) from(select 'liuqudanxinzhaohanqing!' as a) as t;-- 2、返回字符串 'liuqudanxinzhaohanqing!' 中 'zhao'的起始位置select locate('zhao','liuqudanxinzhaohanqing!');-- 在字符串 'liuqudanxinzhaohanqing!' 中 'zhao'的后面插入'文天祥'select locate('zhao','liuqudanxinzhaohanqing!');select concat(left(a,locate('zhao',a) - 1 + length('zhao')),'文天祥',right(a,locate('zhao',a) - length('zhao'))) from(select 'liuqudanxinzhaohanqing!' as a) as t;select right(a,locate('zhao',a) - length('zhao')) from(select 'liuqudanxinzhaohanqing!' as a) as t;select left(a,locate('zhao',a) - 1 + length('zhao')) from(select 'liuqudanxinzhaohanqing!' as a) as t;select locate('zhao',a) from(select 'liuqudanxinzhaohanqing!' as a) as t;select locate('zhao','liuqudanxinzhaohanqing!');select left('liuqudanxinzhaohanqing!',2);select substr(a,locate('zhao',a)) from(select 'liuqudanxinzhaohanqing!' as a) as t;select substr(a,1,locate('zhao',a)) from(select 'liuqudanxinzhaohanqing!' as a) as t;select insert(a,locate('zhao',a) + length('zhao'),'文天祥') as `insert` from(select 'liuqudanxinzhaohanqing!' as a) as t;-- 把字符串 'liuqudanxinzhaohanqing!' 中 'zhao' 截取出来select substr(a,locate('zhao',a),length('zhao')) from(select 'liuqudanxinzhaohanqing!' as a) as t;-- 5、返回字符串的字符数select char_length('有志者,事竟成,破釜沉舟,百二秦关终属楚。有心人,天不负,卧薪尝胆,三千越甲可吞吴。'); # 42-- 6、把字符串 的逗号替换成空格select replace('有志者,事竟成,破釜沉舟,百二秦关终属楚。有心人,天不负,卧薪尝胆,三千越甲可吞吴。',',',' ');-- 7、把字符串 的前十二个字符,提取出来select left('有志者,事竟成,破釜沉舟,百二秦关终属楚。有心人,天不负,卧薪尝胆,三千越甲可吞吴。',12);--把所有学生名字拼接起来,用英文逗号分隔 。select concat_ws(',','Jim','Jack','Luce','Andy');-- 9、4的10次方是多少 ?select power(4,10);-- 10、8开平方是多少 ?select sqrt(8);-- 11、80度的余弦值是多少 ?select cos(radians(80));-- 12、3.14 向上取整 。select ceil(3.14);-- 截止 2021年03月20日 12:00:00 ,2021年已经过去多少时间 ?select (t.end - t.start)/86400 as f from (select unix_timestamp('2021-03-20 12:00:00') as end,unix_timestamp('2021-01-01 00:00:00') as start) as t;select date_format('2021-03-20 12:00:00','%j');select datediff('2021-01-01 00:00:00','2021-03-20 12:00:00');select (t.end - t.start)/86400 as f from (select unix_timestamp('2021-03-20 12:00:00') end,unix_timestamp('2021-01-01 00:00:00') start) t;-- 获取 2021年12月20日 的下月第一天 和上月最后一天。 提示:多函数配合使用select adddate(last_day('2021-12-20'), interval 1 day);select last_day(adddate('2021-12-20', interval -1 month));select adddate('2021-12-20',interval -1 month);select last_day('2021-12-20');select concat(date_format('2021-12-20' + interval 1 month,'%Y-%m-'),'1');select date_format('2021-12-20','%d');
