wnguh

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

随笔分类 -  mysql

摘要:SELECT FLOOR( 500 + ( RAND( ) *1000 ) ) SELECT * FROM `c_company` ORDER BY id =21 DESC , id ASC 阅读全文
posted @ 2012-09-23 21:31 wnguh 阅读(224) 评论(0) 推荐(0)

摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=u 阅读全文
posted @ 2012-07-30 16:03 wnguh 阅读(428) 评论(0) 推荐(0)

摘要:今天在学习maatkit的mk-query-digest这个强大的工具,它能分析慢查询日志,也可以对当前的语句进行分析。所以要启用MySQL的log-slow-queries(慢查询记录)。 在Linux环境下先要找到my.cnf文件(一般在/etc/mysql/),然后可能会发现该文件修改后无法保存,原因是你没有相应的权限,可以从属性中看到该文件的所有者是root,这时要先以root的身份打开它: sudo nautilus /etc/mysql 接着再打开my.cnf文件然后找到[mysqld]标签在下面加上: log-slow-queries=/path/slow.log –慢日志保存. 阅读全文
posted @ 2012-06-18 16:08 wnguh 阅读(4058) 评论(0) 推荐(0)

摘要:convert( smallbooking, signed )转整形 阅读全文
posted @ 2012-02-03 13:32 wnguh 阅读(226) 评论(0) 推荐(0)

摘要:1、将时间转换为时间戳select unix_timestamp('2009-10-26 10-06-07')如果参数为空,则处理为当前时间2、将时间戳转换为时间select from_unixtime(1256540102)有些应用生成的时间戳是比这个多出三位,是毫秒表示,如果要转换,需要先将最后三位去掉,否则返回NULLselect date_format(日期字段,’%Y-%m-%d’) as ‘日期’ from test 阅读全文
posted @ 2011-11-24 17:12 wnguh 阅读(20077) 评论(0) 推荐(3)

摘要:select name from order where oderid in(111,222,333,444,555,666) order by instr('111,222,333,444,555,666',orderid) 阅读全文
posted @ 2011-11-21 16:20 wnguh 阅读(211) 评论(0) 推荐(1)

摘要:二、拆分成2段字段内容aaa,bbbSELECT title, logopath, link, LEFT( info, (INSTR( info, ',' ) -1 )) AS info1, SUBSTRING( info, (INSTR( info, ',' ) +1 )) AS info2 FROM site_photo_info WHERE Pclass = '991' order by addtime desc二、拆分成3段字段内容aaa,bbb,cccSELECT title, logopath, link,LEFT( info, (I 阅读全文
posted @ 2011-11-04 15:50 wnguh 阅读(826) 评论(0) 推荐(0)