![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
mysql
silence-hgt
php软件工程师。c语言学习使用者。
展开
-
MYSQL避免批量插入重复数据报错的解决方案
在mysql中,想要批量的插入数据到数据库,会使用这样的语句 INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date'), ('Another title', 'Another name', 'Another date') 但是如果此时数据库在这些字...原创 2018-07-05 17:49:51 · 6390 阅读 · 0 评论 -
MySQL ifnull 查询中判断
查询结果如果不存在可以在sql中直接对结果进行判断赋值,避免查询出结果后采用后端语言进行判断再处理。 采用方法是MySQL ifnull方法。 IFNULL(expression_1,expression_2) 解释:如果expression_1不为NULL,则IFNULL函数返回expression_1; 否则返回expression_...原创 2018-07-05 18:39:39 · 6625 阅读 · 0 评论 -
MySQL 字符串转时间戳
在php等后台语言中想要将字符串转换成时间戳是非常方便的,但是在mysql中并没有直接提供相应的函数进行直接转换,或者说对于特殊的字符串转换效果并不理想。但是MySQL中存在丰富的时间处理函数,可以组合进行处理,以达到效果。 采用下面的方法可以将字符串转换成 Unix时间戳 SELECT unix_timestamp(str_to_date('2018...原创 2018-07-05 18:58:55 · 3433 阅读 · 0 评论 -
MySQL查询表中重复字段和重复的次数
查询user表中,user_name字段值重复的数据及重复次数select user_name,count(*) as count from user group by user_name having count>1;原创 2018-07-06 17:32:09 · 14294 阅读 · 2 评论