---
title: "Mysql 语句积累"
author: "stevenjohn"
date: "2011-05-17T23:56:53Z"
tags: []
categories: ["数据库"]
slug: "mysql"
draft: false
lastmod: "2011-05-31T02:08:54Z"
id: 1047777
url: "https://stevenjohn.iteye.com/blog/1047777"
---

```java

//向表中插入记录
insert into ff (username,record,log) values ('stevenjohn','mysqllog','logrecord');
//从表中去十条记录
select * from ff  limit 10
//取出来据现在最近的一条记录
select * from (select * from ff  order by createtime desc) as t  limit 1
//查询记录数
select count(*) from ff
//根据record，createtime 查询出来记录数
select record,createtime,count(record) from ff where username='stevenjohn' group by record,createtime order by createtime desc

select record,createtime,count(record) from ff where username='stevenjohn' group by record,createtime order by count(record) desc
//获取Mysql系统时间
select now() as systime
select sysdate() as systime
select current_date as systime
//
select * from abing where to_days(sysdate())=to_days(createtime);
select * from abing where to_days(sysdate())=to_days(createtime);
 select * from abing where str_to_date(now(),'%Y-%m-%d')=str_to_date(createtime,'%Y-%m-%d');



```