![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
mysql
Slimlady
这个作者很懒,什么都没留下…
展开
-
mysql之select into
1.INSERT INTO SELECT语句语句形式为:Insert into Table2(field1,field2,...) select value1,value2,... from Table1要求目标表Table2必须存在,由于目标表Table2已经存在,所以我们除了插入源表Table1的字段外,还可以插入常量。2.SELECT INTO FROM语句语句形式为:SELECT vale1原创 2015-11-04 23:28:41 · 608 阅读 · 0 评论 -
mysql之DATE_FORMAT
select DATE_FORMAT(create_time,'%Y%u') weeks,count(caseid) count from tc_case group by weeks; select DATE_FORMAT(create_time,'%Y%m%d') days,count(caseid) count from tc_case group by days; select DA原创 2015-11-04 23:29:41 · 484 阅读 · 0 评论 -
mysql之触发器trigger
触发器(trigger):监视某种情况,并触发某种操作。触发器创建语法四要素:1.监视地点(table) 2.监视事件(insert/update/delete) 3.触发时间(after/before) 4.触发事件(insert/update/delete)语法:create trigger triggerNameafter/before insert/update/原创 2015-11-04 23:41:32 · 376 阅读 · 0 评论 -
mysql 主从复制
配置Master 在[mysqld]加上log-bin = master-bin log-bin-index =master-bin.index server-id=1在master 上创建一个复制用户 create user repl_user; grant replication slave on . to repl_user IDENTIFIED BY ‘1234’配置SLAVE在原创 2015-11-04 23:27:44 · 355 阅读 · 0 评论 -
mysql之分组 取前二
Select * FROM orders A Where EXISTS(Select COUNT(1) FROM orders Where employeeid= A.employeeid AND orderid> A.orderidHAVING COUNT(1)< 3) ORDER BY EmployeeID原创 2015-11-04 23:26:19 · 500 阅读 · 0 评论 -
mysql之两个日期间隔天数
1 .利用TO_DAYS函数select to_days(now()) - to_days('20120512') 2、利用DATEDIFF函数select datediff(now(),'20120512')原创 2015-11-04 23:31:49 · 868 阅读 · 0 评论 -
MySql之按周,按月,按日分组统计数据
select DATE_FORMAT(create_time,'%Y%u') weeks,count(caseid) count from tc_case group by weeks; select DATE_FORMAT(create_time,'%Y%m%d') days,count(caseid) count from tc_case group by days; select DA原创 2015-11-04 23:25:30 · 483 阅读 · 0 评论 -
mysql 常用函数【整理】
mysql 常用函数对于针对字符串位置的操作,第一个位置被标记为1。 ASCII(str) 返回字符串str的最左面字符的ASCII代码值。如果str是空字符串,返回0。如果str是NULL,返回NULL。 mysql> select ASCII('2'); -> 50mysql> select ASCII(2); -> 50mysql> select ASCII('dx原创 2015-09-05 23:08:56 · 3003 阅读 · 0 评论 -
游标demo
CREATE PROCEDURE `process_mengbao`()BEGIN-- 遍历数据结束标志DECLARE done INT DEFAULT FALSE;-- 符合要求的手机号码DECLARE _mobile CHAR(16);DECLARE _user_id MEDIUMINT(8);-- 游标DECLARE cur CURSOR FOR SELECT id,mo原创 2015-04-24 17:27:03 · 420 阅读 · 0 评论