mysql知识累积

--mysql知识累积
mysql>grant all privileges on *.* to 'root'@'%' identified by 'youpassword' with grant option;
mysql>flush privileges;

mysql -h x.x.x.x -u root -p;

select id, phone,time from user where phone='xxxxxx'                        #
select id, phone,time,year(time) from user where phone='xxxxxx'                       #分别取年
select id, phone,time,month(time) from user where phone='xxxxxx'                    #分别取月
select id, phone,time,DAY(time) from user where phone='xxxxxx'                       #分别取日
select id, phone,time,TIME(time) from user where phone='xxxxxx'                      #分别取时间

--mysql常用函数大全
1、CONCAT(str1,str2,...) 
返回来自于参数连结的字符串。如果任何参数是NULL,返回NULL。可以有超过2个的参数。一个数字参数被变换为等价的字符串形式。 
mysql> select CONCAT('My', 'S', 'QL');
2、LOCATE(substr,str)
POSITION(substr IN str)
返回子串substr在字符串str第一个出现的位置,如果substr不是在str里面,返回0. 
3、LOAD_FILE(file_name) 
读入文件并且作为一个字符串返回文件内容。文件必须在服务器上,你必须指定到文件的完整路径名,而且你必须有file权限。文件必须所有内容都是可读的并且小于max_allowed_packet。如果文件不存在或由于上面原因之一不能被读出,函数返回NULL。 
mysql> UPDATE table_name
      SET blob_column=LOAD_FILE("/tmp/picture")
      WHERE id=1;

  4、DAYOFWEEK(date)  
  返回日期date的星期索引(1=星期天,2=星期一, ……7=星期六)。这些索引值对应于ODBC标准。  
  mysql> select DAYOFWEEK('1998-02-03');  
  -> 3 

  5、WEEKDAY(date)  
  返回date的星期索引(0=星期一,1=星期二, ……6= 星期天)。  
  mysql> select WEEKDAY('1997-10-04 22:23:00');  
  -> 5  




转载于:https://www.cnblogs.com/zmdd/p/8609710.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值