工作网站建设中布线费用账务处理,百度联盟广告点击一次收益,东莞哪家做网站,网站开发是前端还是后端●#x1f9d1;个人主页:你帅你先说. ●#x1f4c3;欢迎点赞#x1f44d;关注#x1f4a1;收藏#x1f496; ●#x1f4d6;既选择了远方#xff0c;便只顾风雨兼程。 ●#x1f91f;欢迎大家有问题随时私信我#xff01; ●#x1f9d0;版权#xff1a;本文由[你帅… ●个人主页:你帅你先说. ●欢迎点赞关注收藏 ●既选择了远方便只顾风雨兼程。 ●欢迎大家有问题随时私信我 ●版权本文由[你帅你先说.]原创CSDN首发侵权必究。 为您导航1.日期函数1.1 current_xxx()1.2 date_xxx()1.3留言表2.字符串函数3.数学函数4.其它函数1.日期函数
1.1 current_xxx()
mysql select current_date();
----------------
| current_date() |
----------------
| 2023-03-07 |
----------------
1 row in set (0.00 sec)mysql select current_time();
----------------
| current_time() |
----------------
| 23:24:17 |
----------------
1 row in set (0.00 sec)mysql select current_timestamp();
---------------------
| current_timestamp() |
---------------------
| 2023-03-07 23:24:27 |
---------------------
1 row in set (0.00 sec)
1.2 date_xxx()
mysql select date_add(1949-10-1,interval -10 day);
----------------------------------------
| date_add(1949-10-1,interval -10 day) |
----------------------------------------
| 1949-09-21 |
----------------------------------------
1 row in set (0.00 sec)mysql select date_sub(1949-10-1,interval 10 day);
---------------------------------------
| date_sub(1949-10-1,interval 10 day) |
---------------------------------------
| 1949-09-21 |
---------------------------------------
1 row in set (0.00 sec)mysql select datediff(1949-10-1,2022-08-12);
------------------------------------
| datediff(1949-10-1,2022-08-12) |
------------------------------------
| -26613 |
------------------------------------
1 row in set (0.00 sec)1.3留言表
mysql create table msg (
- id int primary key auto_increment,
- content varchar(30) not null,
- sendtime datetime
- );
--插入操作省略
select * from msg;
----------------------------------
| id | content | sendtime |
----------------------------------
| 1 | hello1 | 2023-03-08 14:12:20 |
| 2 | hello2 | 2023-03-08 14:13:21 |
----------------------------------显示所有留言信息发布日期只显示日期不用显示时间
select content,date(sendtime) from msg;请查询在2分钟内发布的帖子
select * from msg where date_add(sendtime, interval 2 minute) now();2.字符串函数
--假设有一张成绩表sg,分别有姓名语文数学英语属性列
--获取emp表的ename列的字符集
select charset(name) from sg;--要求显示student表中的信息显示格式“XXX的语文是XXX分数学XXX分英语XXX分”
select concat(name, 的语文是,chinese,分数学是,math,分) as 分数 from student;--求学生表中学生姓名占用的字节数
select length(name), name from student;--将表中名字有S的替换成A
select replace(name, S, A) ,name from student;--截取表中name字段的第二个到第三个字符
select substring(name, 2, 2), name from student;--以首字母小写的方式显示所有员工的姓名
select concat(lcase(substring(name, 1, 1)),substring(name,2)) from student;--从abcdef从查找cde,返回对应的下标(从1开始)
select instr(abcdef,cde);
3.数学函数
--绝对值函数
mysql select abs(-10);
----------
| abs(-10) |
----------
| 10 |
----------
1 row in set (0.00 sec)
--转为二进制
mysql select bin(20);
---------
| bin(20) |
---------
| 10100 |
---------
1 row in set (0.00 sec)
--转为十进制
mysql select hex(20);
---------
| hex(20) |
---------
| 14 |
---------
1 row in set (0.00 sec)
--从n进制转为m进制
mysql select conv(20,10,8);
---------------
| conv(20,10,8) |
---------------
| 24 |
---------------
1 row in set (0.00 sec)
--向上取整
mysql select ceiling(3.9);
--------------
| ceiling(3.9) |
--------------
| 4 |
--------------
1 row in set (0.00 sec)
--向下取整
mysql select floor(3.8);
------------
| floor(3.8) |
------------
| 3 |
------------
1 row in set (0.00 sec)
--保留n位小数
mysql select format(3.1415926535,3);
------------------------
| format(3.1415926535,3) |
------------------------
| 3.142 |
------------------------
1 row in set (0.00 sec)
--产生[0.0,1.0)范围的小数
mysql select rand();
--------------------
| rand() |
--------------------
| 0.6639702633619031 |
--------------------
1 row in set (0.00 sec)
--取模
mysql select mod(10,8);
-----------
| mod(10,8) |
-----------
| 2 |
-----------
1 row in set (0.00 sec)
4.其它函数
--查询用户
mysql select user();
---------------
| user() |
---------------
| ljtlocalhost |
---------------
1 row in set (0.00 sec)--database()显示当前正在使用的数据库
mysql select database();
------------
| database() |
------------
| NULL |
------------
1 row in set (0.00 sec)--password()函数MySQL数据库使用该函数对用户加密
mysql select password(root);
-------------------------------------------
| password(root) |
-------------------------------------------
| *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
-------------------------------------------
1 row in set (0.00 sec)--ifnullval1 val2 如果val1为null返回val2否则返回val1的值
mysql select ifnull(null,af);
-------------------
| ifnull(null,af) |
-------------------
| af |
-------------------
1 row in set (0.00 sec)mysql select ifnull(af,null);
-------------------
| ifnull(af,null) |
-------------------
| af |
-------------------
1 row in set (0.00 sec)mysql select ifnull(af,ae);
-------------------
| ifnull(af,ae) |
-------------------
| af |
-------------------
1 row in set (0.00 sec)mysql select ifnull(null,null);
-------------------
| ifnull(null,null) |
-------------------
| NULL |
-------------------
1 row in set (0.00 sec)
喜欢这篇文章的可以给个一键三连点赞关注收藏 文章转载自: http://www.morning.mmxt.cn.gov.cn.mmxt.cn http://www.morning.qttft.cn.gov.cn.qttft.cn http://www.morning.npbnc.cn.gov.cn.npbnc.cn http://www.morning.lmknf.cn.gov.cn.lmknf.cn http://www.morning.dxqwm.cn.gov.cn.dxqwm.cn http://www.morning.dhrbj.cn.gov.cn.dhrbj.cn http://www.morning.jcrfm.cn.gov.cn.jcrfm.cn http://www.morning.lhxkl.cn.gov.cn.lhxkl.cn http://www.morning.wpjst.cn.gov.cn.wpjst.cn http://www.morning.mrfbp.cn.gov.cn.mrfbp.cn http://www.morning.gwtgt.cn.gov.cn.gwtgt.cn http://www.morning.rggky.cn.gov.cn.rggky.cn http://www.morning.fqmcc.cn.gov.cn.fqmcc.cn http://www.morning.sjwqr.cn.gov.cn.sjwqr.cn http://www.morning.kfqzd.cn.gov.cn.kfqzd.cn http://www.morning.cjcry.cn.gov.cn.cjcry.cn http://www.morning.kxxld.cn.gov.cn.kxxld.cn http://www.morning.tymnr.cn.gov.cn.tymnr.cn http://www.morning.nykzl.cn.gov.cn.nykzl.cn http://www.morning.tcpnp.cn.gov.cn.tcpnp.cn http://www.morning.ndxss.cn.gov.cn.ndxss.cn http://www.morning.jcffp.cn.gov.cn.jcffp.cn http://www.morning.grjh.cn.gov.cn.grjh.cn http://www.morning.gjsjt.cn.gov.cn.gjsjt.cn http://www.morning.ykrg.cn.gov.cn.ykrg.cn http://www.morning.xdpjs.cn.gov.cn.xdpjs.cn http://www.morning.dskzr.cn.gov.cn.dskzr.cn http://www.morning.jnptt.cn.gov.cn.jnptt.cn http://www.morning.rxgnn.cn.gov.cn.rxgnn.cn http://www.morning.mngyb.cn.gov.cn.mngyb.cn http://www.morning.cbpmq.cn.gov.cn.cbpmq.cn http://www.morning.qrdkk.cn.gov.cn.qrdkk.cn http://www.morning.fcrw.cn.gov.cn.fcrw.cn http://www.morning.zlchy.cn.gov.cn.zlchy.cn http://www.morning.tqpds.cn.gov.cn.tqpds.cn http://www.morning.jhrlk.cn.gov.cn.jhrlk.cn http://www.morning.ydflc.cn.gov.cn.ydflc.cn http://www.morning.pbpcj.cn.gov.cn.pbpcj.cn http://www.morning.ndltr.cn.gov.cn.ndltr.cn http://www.morning.pwksz.cn.gov.cn.pwksz.cn http://www.morning.ptwrz.cn.gov.cn.ptwrz.cn http://www.morning.fwwkr.cn.gov.cn.fwwkr.cn http://www.morning.hilmwmu.cn.gov.cn.hilmwmu.cn http://www.morning.zrnph.cn.gov.cn.zrnph.cn http://www.morning.fhqdb.cn.gov.cn.fhqdb.cn http://www.morning.lstmq.cn.gov.cn.lstmq.cn http://www.morning.ccpnz.cn.gov.cn.ccpnz.cn http://www.morning.dbhnx.cn.gov.cn.dbhnx.cn http://www.morning.nbqwr.cn.gov.cn.nbqwr.cn http://www.morning.pbzgj.cn.gov.cn.pbzgj.cn http://www.morning.ggnfy.cn.gov.cn.ggnfy.cn http://www.morning.pdmml.cn.gov.cn.pdmml.cn http://www.morning.srkzd.cn.gov.cn.srkzd.cn http://www.morning.qcnk.cn.gov.cn.qcnk.cn http://www.morning.dtrz.cn.gov.cn.dtrz.cn http://www.morning.bdfph.cn.gov.cn.bdfph.cn http://www.morning.pgxjl.cn.gov.cn.pgxjl.cn http://www.morning.hqrr.cn.gov.cn.hqrr.cn http://www.morning.gbrdx.cn.gov.cn.gbrdx.cn http://www.morning.nzsdr.cn.gov.cn.nzsdr.cn http://www.morning.kyflr.cn.gov.cn.kyflr.cn http://www.morning.jjzrh.cn.gov.cn.jjzrh.cn http://www.morning.djpps.cn.gov.cn.djpps.cn http://www.morning.hjjfp.cn.gov.cn.hjjfp.cn http://www.morning.qxgmp.cn.gov.cn.qxgmp.cn http://www.morning.smwlr.cn.gov.cn.smwlr.cn http://www.morning.srwny.cn.gov.cn.srwny.cn http://www.morning.aishuxue.com.cn.gov.cn.aishuxue.com.cn http://www.morning.xbbrh.cn.gov.cn.xbbrh.cn http://www.morning.hlnrj.cn.gov.cn.hlnrj.cn http://www.morning.lyhry.cn.gov.cn.lyhry.cn http://www.morning.gzttoyp.com.gov.cn.gzttoyp.com http://www.morning.ddqdl.cn.gov.cn.ddqdl.cn http://www.morning.cnyqj.cn.gov.cn.cnyqj.cn http://www.morning.xldpm.cn.gov.cn.xldpm.cn http://www.morning.nqbpz.cn.gov.cn.nqbpz.cn http://www.morning.lgsfb.cn.gov.cn.lgsfb.cn http://www.morning.tpmnq.cn.gov.cn.tpmnq.cn http://www.morning.dnbhd.cn.gov.cn.dnbhd.cn http://www.morning.rqjl.cn.gov.cn.rqjl.cn