易截截图软件、单文件、免安装、纯绿色、仅160KB

mysql 中 时间和日期函数

基础部分
一、MySQL 获得当前日期时间 函数
1.1 获得当前日期+时间(date + time)函数:now()
mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2008-08-08 22:20:46 |
+---------------------+
除了 now() 函数能获得当前的日期时间外,MySQL 中还有下面的函数:
 current_timestamp()
,current_timestamp
,localtime()
,localtime
,localtimestamp    -- (v4.0.6)
,localtimestamp()  -- (v4.0.6)
这些日期时间函数,都等同于 now()。鉴于 now() 函数简短易记,建议总是使用 now() 来替代上面列出的函数。
1.2 获得当前日期+时间(date + time)函数:sysdate()
sysdate() 日期时间函数跟 now() 类似,不同之处在于:now() 在执行开始时值就得到了, sysdate() 在函数执行时动态得到值。看下面的例子就明白了:
mysql> select now(), sleep(3), now();
+---------------------+----------+---------------------+
| now()               | sleep(3) | now()               |
+---------------------+----------+---------------------+
| 2008-08-08 22:28:21 |        0 | 2008-08-08 22:28:21 |
+---------------------+----------+---------------------+
mysql> select sysdate(), sleep(3), sysdate();
+---------------------+----------+---------------------+
| sysdate()           | sleep(3) | sysdate()           |
+---------------------+----------+---------------------+
| 2008-08-08 22:28:41&nbs


相关文档:

mysql出现unauthenticated user简单分析以及解决

当用show processlist;看到如下信息时:
LL | login | NULL             |
| 697 | unauthenticated user | 218.26.219.186:26944  | NULL       | Connect | NULL | login | NULL      & ......

MySQL中group_concat函数


本文通过实例介绍了MySQL中的group_concat函数的使用方法,比如select group_concat(name) 。
MySQL中group_concat函数
完整的语法如下:
group_concat([DISTINCT] 要连接的字段 [Order BY ASC/DESC 排序字段] [Separator '分隔符'])
基本查询
mysql> select * from aa;
+------+------+
| id| name |
+----- ......

基础 JAVA对Mysql进行连接、插入、修改、删除操作

数据库表单的创建
mysql> create database shuishengmu;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql    & ......

Mysql问题汇总

1,Mysql插入二进制大对象出现异常,插入二进制出现异常,怎么解决com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
解决办法:url=url=+"?useUnicode=true& ......

mysql distinct 对多字段过滤不正确的解决方法


下面先来看看例子:
    table
  id name
  1 a
  2 b
  3 c
  4 c
  5 b
库结构大概这样,这只是一个简单的例子,实际情况会复杂得多。
比如我想用一条语句查询得到name不重复的所有数据,那就必须使用distinct去掉多余的重复记录 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号