+------------------+
| 0 |
+------------------+
1 row in set (0.00 sec)
mysql> select round(242.38,-2);
+------------------+
| round(242.38,-2) |
+------------------+
| 200 |
+------------------+
1 row in set (0.00 sec)
mysql> select round(842.38,-2);
+------------------+
| round(842.38,-2) |
+------------------+
| 800 |
+------------------+
1 row in set (0.00 sec)
mysql> select truncate(1.31,1);
+------------------+
| truncate(1.31,1) |
+------------------+
| 1.3 |
+------------------+
1 row in set (0.00 sec)
mysql> select truncate(1.35,1);
+------------------+
| truncate(1.35,1) |
+------------------+
| 1.3 |
+------------------+
1 row in set (0.00 sec)
mysql> select truncate(1.9999,1);
+--------------------+
| truncate(1.9999,1) |
+--------------------+
| 1.9 |
+--------------------+
1 row in set (0.00 sec)
mysql> select pow(2,2),power(2,2),pow(2,-2),power(2,-2);
+----------+------------+-----------+-------------+
| pow(2,2) | power(2,2) | pow(2,-2) | power(2,-2) |
+----------+------------+-----------+-------------+
| 4 | 4 | 0.25 | 0.25 |
+----------+------------+-----------+-------------+
1 row in set (0.02 sec)
mysql> select exp(2);
+------------------+
| exp(2) |
+------------------+
| 7.38905609893065 |
+------------------+
1 row in set (0.00 sec)
mysql> select exp(0);
+--------+
| exp(0) |
+--------+
| 1 |
+--------+
1 row in set (0.00 sec)
mysql> select exp(-3)
-> ;
+----------------------+
| exp(-3) |
+----------------------+
| 0.049787068367863944 |
+----------------------+
1 row in set (0.00 sec)
mysql> select log(3);
+--------------------+
| log(3) |
+--------------------+
| 1.0986122886681098 |
+--------------------+
1 row in set (0.00 sec)
mysql> select log10(10);
+-----------+
| log10(10) |
+-----------+
| 1 |
+-----------+
1 row in set (0.00 sec)
mysql> select log10(100);
+------------+
| log10(100) |
+------------+
| 2 |
+------------+
1 row in set (0.00 sec)
mysql> select log10(-100);
+-------------+
| log10(-100) |
+-------------+
| NULL |
+-------------+
1 row in set (0.00 sec)
mysql> select char_length('date');
+---------------------+
| char_length('date') |
+---------------------+
| 4 |
+---------------------+
1 row in set (0.00 sec)
mysql> select char_length('egg');
+--------------------+
| char_length('egg') |
+--------------------+
| 3 |
+--------------------+
1 row in set (0.00 sec)
mysql> select length('lisheng');
+-------------------+
| length('lisheng') |
+-------------------+
| 7 |
+-------------------+
1 row in set (0.00 sec)
mysql> select length('date');
+----------------+
| length('date') |
+----------------+
| 4 |
+----------------+
1 row in set (0.00 sec)
mysql> select concat('My SQL','5.6');
+------------------------+
| concat('My SQL','5.6') |
+------------------------+
| My SQL5.6 |
+------------------------+
1 row in set (0.02 sec)
mysql> select concat('Mysql','5.6');
+-----------------------+
| concat('Mysql','5.6') |
+-----------------------+
| Mysql5.6 |
+-----------------------+
1 row in set (0.00 sec)
mysql> select concat('my',null,'sql');
+-------------------------+
| concat('my',null,'sql') |
+-------------------------+
| NULL |
+-------------------------+
1 row in set (0.00 sec)
mysql> select
->
->
->
->
->
->
->
->
->
->
-> -> Ctrl-C -- exit!
->
->
->
->
->
->
->
->
-> ;
ERROR 1064 (42000): 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
mysql> select concat_ws('-','1st','2nd','3rd');
+----------------------------------+
| concat_ws('-','1st','2nd','3rd') |
+----------------------------------+
| 1st-2nd-3rd |
+----------------------------------+
1 row in set (0.02 sec)
mysql> select concat_ws('*','1st',NULL,'3rd');
+---------------------------------+
| concat_ws('*','1st',NULL,'3rd') |
+---------------------------------+
| 1st*3rd |
+---------------------------------+
1 row in set (0.00 sec)
mysql> select insert('Quest',2,4,'What') AS coll,
-> insert('Quest',-1,4,'What') as col2,
-> insert('Quest',3,100,'Wh') as col3;
+-------+-------+------+
| coll | col2 | col3 |
+-------+-------+------+
| QWhat | Quest | QuWh |
+-------+-------+------+
1 row in set (0.00 sec)
mysql> select lower('LISHENG');
+------------------+
| lower('LISHENG') |
+------------------+
| lisheng |
+------------------+
1 row in set (0.00 sec)
mysql> select lcase(
-> 'Well');
+----------------+
| lcase(
'Well') |
+----------------+
| well |
+----------------+
1 row in set (0.00 sec)
mysql> select upper('lisheng');
+------------------+
| upper('lisheng') |
+------------------+
| LISHENG |
+------------------+
1 row in set (0.00 sec)
mysql> select left('football',5);
+--------------------+
| left('football',5) |
+--------------------+
| footb |
+--------------------+
1 row in set (0.00 sec)
mysql> select left('lisheng',2);
+-------------------+
| left('lisheng',2) |
+-------------------+
| li |
+-------------------+
1 row in set (0.00 sec)
mysql> select right('lisheng',5);
+--------------------+
| right('lisheng',5) |
+--------------------+
| sheng |
+--------------------+
1 row in set (0.00 sec)
mysql> select lpad('hello',4,'??');
+----------------------+
| lpad('hello',4,'??') |
+----------------------+
| hell |
+----------------------+
1 row in set (0.00 sec)
mysql> select lpad('hello',10,'>>');
+-----------------------+
| lpad('hello',10,'>>') |
+-----------------------+
| >>>>>hello |
+-----------------------+
1 row in set (0.00 sec)
mysql> select rpad('hello',4,"?");
+---------------------+
| rpad('hello',4,"?") |
+---------------------+
| hell |
+---------------------+
1 row in set (0.00 sec)
mysql> select RPAD('hello',10,"?");
+----------------------+
| RPAD('hello',10,"?") |
+----------------------+
| hello????? |
+----------------------+
1 row in set (0.00 sec)
mysql>
| concat('My SQL','5.6') |
+------------------------+
| My SQL5.6 |
+------------------------+
1 row in set (0.02 sec)
mysql> select concat('Mysql','5.6');
+-----------------------+
| concat('Mysql','5.6') |
+-----------------------+
| Mysql5.6 |
+-----------------------+
1 row in set (0.00 sec)
mysql> select concat('my',null,'sql');
+-------------------------+
| concat('my',null,'sql') |
+-------------------------+
| NULL |
+-------------------------+
1 row in set (0.00 sec)
mysql> select
->
->
->
->
->
->
->
->
->
->
-> -> Ctrl-C -- exit!
->
->
->
->
->
->
->
->
-> ;
ERROR 1064 (42000): 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
mysql> select concat_ws('-','1st','2nd','3rd');
+----------------------------------+
| concat_ws('-','1st','2nd','3rd') |
+----------------------------------+
| 1st-2nd-3rd |
+----------------------------------+
1 row in set (0.02 sec)
mysql> select concat_ws('*','1st',NULL,'3rd');
+---------------------------------+
| concat_ws('*','1st',NULL,'3rd') |
+---------------------------------+
| 1st*3rd |
+---------------------------------+
1 row in set (0.00 sec)
mysql> select insert('Quest',2,4,'What') AS coll,
-> insert('Quest',-1,4,'What') as col2,
-> insert('Quest',3,100,'Wh') as col3;
+-------+-------+------+
| coll | col2 | col3 |
+-------+-------+------+
| QWhat | Quest | QuWh |
+-------+-------+------+
1 row in set (0.00 sec)
mysql> select lower('LISHENG');
+------------------+
| lower('LISHENG') |
+------------------+
| lisheng |
+------------------+
1 row in set (0.00 sec)
mysql> select lcase(
-> 'Well');
+----------------+
| lcase(
'Well') |
+----------------+
| well |
+----------------+
1 row in set (0.00 sec)
mysql> select upper('lisheng');
+------------------+
| upper('lisheng') |
+------------------+
| LISHENG |
+------------------+
1 row in set (0.00 sec)
mysql> select left('football',5);
+--------------------+
| left('football',5) |
+--------------------+
| footb |
+--------------------+
1 row in set (0.00 sec)
mysql> select left('lisheng',2);
+-------------------+
| left('lisheng',2) |
+-------------------+
| li |
+-------------------+
1 row in set (0.00 sec)
mysql> select right('lisheng',5);
+--------------------+
| right('lisheng',5) |
+--------------------+
| sheng |
+--------------------+
1 row in set (0.00 sec)
mysql> select lpad('hello',4,'??');
+----------------------+
| lpad('hello',4,'??') |
+----------------------+
| hell |
+----------------------+
1 row in set (0.00 sec)
mysql> select lpad('hello',10,'>>');
+-----------------------+
| lpad('hello',10,'>>') |
+-----------------------+
| >>>>>hello |
+-----------------------+
1 row in set (0.00 sec)
mysql> select rpad('hello',4,"?");
+---------------------+
| rpad('hello',4,"?") |
+---------------------+
| hell |
+---------------------+
1 row in set (0.00 sec)
mysql> select RPAD('hello',10,"?");
+----------------------+
| RPAD('hello',10,"?") |
+----------------------+
| hello????? |
+----------------------+
1 row in set (0.00 sec)
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql>
mysql> select '( book )',concat('(',ltrim(' book '),')');
+-----------+-----------------------------------+
| ( book ) | concat('(',ltrim(' book '),')') |
+-----------+-----------------------------------+
| ( book ) | (book ) |
+-----------+-----------------------------------+
1 row in set (0.00 sec)
mysql> select concat('(',rtrim(' book '),')');
+----------------------------------+
| concat('(',rtrim(' book '),')') |
+----------------------------------+
| ( book) |
+----------------------------------+
1 row in set (0.00 sec)
mysql> select concat('(',trim(' book ')',')');
'> ;
'> '
-> ;
ERROR 1583 (42000): Incorrect parameters in the call to native function 'concat'
mysql> select concat(
-> -> Ctrl-C -- exit!
-> ;
ERROR 1064 (42000): 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
mysql> select concat('(',trim(' book '),')');
+-----------------------------------+
| concat('(',trim(' book '),')') |
+-----------------------------------+
| (book) |
+-----------------------------------+
1 row in set (0.00 sec)
mysql> select trim('xy' from 'xyboxxyokxxyxy');
+----------------------------------+
| trim('xy' from 'xyboxxyokxxyxy') |
+----------------------------------+
| boxxyokx |
+----------------------------------+
1 row in set (0.00 sec)
mysql> select repeat('mysql',3);
+-------------------+
| repeat('mysql',3) |
+-------------------+
| mysqlmysqlmysql |
+-------------------+
1 row in set (0.00 sec)
mysql> select repeat('lisheng is a good man',4);
+-------------------------------------------------------------------------------
-------+
| repeat('lisheng is a good man',4)
|
+-------------------------------------------------------------------------------
-------+
| lisheng is a good manlisheng is a good manlisheng is a good manlisheng is a go
od man |
+-------------------------------------------------------------------------------
-------+
1 row in set (0.00 sec)
mysql> select concat('(',space(6),')');
+--------------------------+
| concat('(',space(6),')') |
+--------------------------+
| ( ) |
+--------------------------+
1 row in set (0.00 sec)
mysql> select replace('xxx.mysql.com','x','w');
+----------------------------------+
| replace('xxx.mysql.com','x','w') |
+----------------------------------+
| www.mysql.com |
+----------------------------------+
1 row in set (0.00 sec)
mysql> select strcmp('txt','txt2'),strcmp('txt2','txt'),strcmp('txt','txt');
+----------------------+----------------------+---------------------+
| strcmp('txt','txt2') | strcmp('txt2','txt') | strcmp('txt','txt') |
+----------------------+----------------------+---------------------+
| -1 | 1 | 0 |
+----------------------+----------------------+---------------------+
1 row in set (0.00 sec)
mysql>
mysql> select substring('breakfast',5) as coll,
-> substring('breakfast',5,3) as col2,
-> substring('lunch',-3) as col3,
-> substring('lunch',-5,3) as col4;
+-------+------+------+------+
| coll | col2 | col3 | col4 |
+-------+------+------+------+
| kfast | kfa | nch | lun |
+-------+------+------+------+
1 row in set (0.00 sec)
mysql> select locate('ball','football');
+---------------------------+
| locate('ball','football') |
+---------------------------+
| 5 |
+---------------------------+
1 row in set (0.00 sec)
mysql> select reverse('abc');
+----------------+
| reverse('abc') |
+----------------+
| cba |
+----------------+
1 row in set (0.00 sec)
mysql> select curdate();
+------------+
| curdate() |
+------------+
| 2015-09-05 |
+------------+
1 row in set (0.03 sec)
mysql> select current_date();
+----------------+
| current_date() |
+----------------+
| 2015-09-05 |
+----------------+
1 row in set (0.00 sec)
mysql> select current_date()+0;
+------------------+
| current_date()+0 |
+------------------+
| 20150905 |
+------------------+
1 row in set (0.00 sec)
mysql> select current_time();
+----------------+
| current_time() |
+----------------+
| 15:15:04 |
+----------------+
1 row in set (0.01 sec)
mysql> select current_time()+0;
+------------------+
| current_time()+0 |
+------------------+
| 151513.000000 |
+------------------+
1 row in set (0.00 sec)
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2015-09-05 15:15:52 |
+---------------------+
1 row in set (0.00 sec)
mysql>mysql> select substring('breakfast',5) as coll,
-> substring('breakfast',5,3) as col2,
-> substring('lunch',-3) as col3,
-> substring('lunch',-5,3) as col4;
+-------+------+------+------+
| coll | col2 | col3 | col4 |
+-------+------+------+------+
| kfast | kfa | nch | lun |
+-------+------+------+------+
1 row in set (0.00 sec)
mysql> select locate('ball','football');
+---------------------------+
| locate('ball','football') |
+---------------------------+
| 5 |
+---------------------------+
1 row in set (0.00 sec)
mysql> select reverse('abc');
+----------------+
| reverse('abc') |
+----------------+
| cba |
+----------------+
1 row in set (0.00 sec)
mysql> select curdate();
+------------+
| curdate() |
+------------+
| 2015-09-05 |
+------------+
1 row in set (0.03 sec)
mysql> select current_date();
+----------------+
| current_date() |
+----------------+
| 2015-09-05 |
+----------------+
1 row in set (0.00 sec)
mysql> select current_date()+0;
+------------------+
| current_date()+0 |
+------------------+
| 20150905 |
+------------------+
1 row in set (0.00 sec)
mysql> select current_time();
+----------------+
| current_time() |
+----------------+
| 15:15:04 |
+----------------+
1 row in set (0.01 sec)
mysql> select current_time()+0;
+------------------+
| current_time()+0 |
+------------------+
| 151513.000000 |
+------------------+
1 row in set (0.00 sec)
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2015-09-05 15:15:52 |
+---------------------+
1 row in set (0.00 sec)
mysql>
mysql> select substring('breakfast',5) as coll,
-> substring('breakfast',5,3) as col2,
-> substring('lunch',-3) as col3,
-> substring('lunch',-5,3) as col4;
+-------+------+------+------+
| coll | col2 | col3 | col4 |
+-------+------+------+------+
| kfast | kfa | nch | lun |
+-------+------+------+------+
1 row in set (0.00 sec)
mysql> select locate('ball','football');
+---------------------------+
| locate('ball','football') |
+---------------------------+
| 5 |
+---------------------------+
1 row in set (0.00 sec)
mysql> select reverse('abc');
+----------------+
| reverse('abc') |
+----------------+
| cba |
+----------------+
1 row in set (0.00 sec)
mysql> select curdate();
+------------+
| curdate() |
+------------+
| 2015-09-05 |
+------------+
1 row in set (0.03 sec)
mysql> select current_date();
+----------------+
| current_date() |
+----------------+
| 2015-09-05 |
+----------------+
1 row in set (0.00 sec)
mysql> select current_date()+0;
+------------------+
| current_date()+0 |
+------------------+
| 20150905 |
+------------------+
1 row in set (0.00 sec)
mysql> select current_time();
+----------------+
| current_time() |
+----------------+
| 15:15:04 |
+----------------+
1 row in set (0.01 sec)
mysql> select current_time()+0;
+------------------+
| current_time()+0 |
+------------------+
| 151513.000000 |
+------------------+
1 row in set (0.00 sec)
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2015-09-05 15:15:52 |
+---------------------+
1 row in set (0.00 sec)
mysql>
mysql> select reverse('abc');
+----------------+
| reverse('abc') |
+----------------+
| cba |
+----------------+
1 row in set (0.00 sec)
mysql> select curdate();
+------------+
| curdate() |
+------------+
| 2015-09-05 |
+------------+
1 row in set (0.03 sec)
mysql> select current_date();
+----------------+
| current_date() |
+----------------+
| 2015-09-05 |
+----------------+
1 row in set (0.00 sec)
mysql> select current_date()+0;
+------------------+
| current_date()+0 |
+------------------+
| 20150905 |
+------------------+
1 row in set (0.00 sec)
mysql> select current_time();
+----------------+
| current_time() |
+----------------+
| 15:15:04 |
+----------------+
1 row in set (0.01 sec)
mysql> select current_time()+0;
+------------------+
| current_time()+0 |
+------------------+
| 151513.000000 |
+------------------+
1 row in set (0.00 sec)
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2015-09-05 15:15:52 |
+---------------------+
1 row in set (0.00 sec)
mysql> select unix_timestamp();
+------------------+
| unix_timestamp() |
+------------------+
| 1441437497 |
+------------------+
1 row in set (0.00 sec)
mysql> select unix_timestamp(now());
+-----------------------+
| unix_timestamp(now()) |
+-----------------------+
| 1441437511 |
+-----------------------+
1 row in set (0.00 sec)
mysql> select unix_timestamp();
+------------------+
| unix_timestamp() |
+------------------+
| 1441437518 |
+------------------+
1 row in set (0.00 sec)
mysql> select from_unixtime('1441437511');
+-----------------------------+
| from_unixtime('1441437511') |
+-----------------------------+
| 2015-09-05 15:18:31 |
+-----------------------------+
1 row in set (0.00 sec)
mysql> select UTC_DATE();
+------------+
| UTC_DATE() |
+------------+
| 2015-09-05 |
+------------+
1 row in set (0.00 sec)
mysql> select MONTH(now());
+--------------+
| MONTH(now()) |
+--------------+
| 9 |
+--------------+
1 row in set (0.00 sec)
mysql> select MONTHNAME(now());
+------------------+
| MONTHNAME(now()) |
+------------------+
| September |
+------------------+
1 row in set (0.01 sec)
mysql> select dayname(now()):
-> ;
ERROR 1064 (42000): 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
mysql> select dayname(now());
+----------------+
| dayname(now()) |
+----------------+
| Saturday |
+----------------+
1 row in set (0.02 sec)
mysql> select day(now()):
-> ;
ERROR 1064 (42000): 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
mysql> select day(now()):
-> ;
ERROR 1064 (42000): 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
mysql> select day(now());
+------------+
| day(now()) |
+------------+
| 5 |
+------------+
1 row in set (0.00 sec)
mysql> select dayofweek(now());
+------------------+
| dayofweek(now()) |
+------------------+
| 7 |
+------------------+
1 row in set (0.00 sec)
mysql> select weekday(now()):
-> ;
ERROR 1064 (42000): 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
mysql> select weekday(now());
+----------------+
| weekday(now()) |
+----------------+
| 5 |
+----------------+
1 row in set (0.00 sec)
mysql> select week(now()):
-> ;
ERROR 1064 (42000): 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
mysql> select week(now());
+-------------+
| week(now()) |
+-------------+
| 35 |
+-------------+
1 row in set (0.00 sec)
mysql> select week(now(),1);
+---------------+
| week(now(),1) |
+---------------+
| 36 |
+---------------+
1 row in set (0.00 sec)
mysql> select week(now(),3);
+---------------+
| week(now(),3) |
+---------------+
| 36 |
+---------------+
1 row in set (0.00 sec)
mysql> select weekofyear(now());
+-------------------+
| weekofyear(now()) |
+-------------------+
| 36 |
+-------------------+
1 row in set (0.00 sec)
mysql> select dayofyear(now());
+------------------+
| dayofyear(now()) |
+------------------+
| 248 |
+------------------+
1 row in set (0.00 sec)
mysql> select dayofmonth(now());
+-------------------+
| dayofmonth(now()) |
+-------------------+
| 5 |
+-------------------+
1 row in set (0.00 sec)
mysql>
mysql> select extract(year from now()) as coll;
+------+
| coll |
+------+
| 2015 |
+------+
1 row in set (0.00 sec)
mysql> select time();
ERROR 1064 (42000): 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
mysql> select date();
ERROR 1064 (42000): 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
mysql> select current_time();
+----------------+
| current_time() |
+----------------+
| 15:42:28 |
+----------------+
1 row in set (0.00 sec)
mysql> select time_to_sec(current_time());
+-----------------------------+
| time_to_sec(current_time()) |
+-----------------------------+
| 56586 |
+-----------------------------+
1 row in set (0.00 sec)
mysql> select sec_to_time(56586);
+--------------------+
| sec_to_time(56586) |
+--------------------+
| 15:43:06 |
+--------------------+
1 row in set (0.00 sec)
mysql> select date_add('2010-12-31 23:59:59',interval 1 second) as coll;
+---------------------+
| coll |
+---------------------+
| 2011-01-01 00:00:00 |
+---------------------+
1 row in set (0.00 sec)
mysql> select date_add(
-> '2010-12-31 23:59:59',interval 1 second) as coll;
+---------------------+
| coll |
+---------------------+
| 2011-01-01 00:00:00 |
+---------------------+
1 row in set (0.00 sec)
mysql> select data_add('2010-12-31 23:59:59',interval '1:1' minute_second);
ERROR 1064 (42000): 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
mysql> select date_add('2010-12-31 23:59:59',interval '1:1' minute_second) ;
+--------------------------------------------------------------+
| date_add('2010-12-31 23:59:59',interval '1:1' minute_second) |
+--------------------------------------------------------------+
| 2011-01-01 00:01:00 |
+--------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> select date_sub('2011-01-02',interval 31 day);
+----------------------------------------+
| date_sub('2011-01-02',interval 31 day) |
+----------------------------------------+
| 2010-12-02 |
+----------------------------------------+
1 row in set (0.00 sec)
mysql> select addtime('2000-12-31 23:59:59','1:1:1'),addtime('02:02:02','02:00:00');
+----------------------------------------+--------------------------------+
| addtime('2000-12-31 23:59:59','1:1:1') | addtime('02:02:02','02:00:00') |
+----------------------------------------+--------------------------------+
| 2001-01-01 01:01:00 | 04:02:02 |
+----------------------------------------+--------------------------------+
1 row in set (0.00 sec)
mysql> select subtime('2000-12-31 23:59:59','1:1:1'),subtime('02:02:02','02:00:00');
+----------------------------------------+--------------------------------+
| subtime('2000-12-31 23:59:59','1:1:1') | subtime('02:02:02','02:00:00') |
+----------------------------------------+--------------------------------+
| 2000-12-31 22:58:58 | 00:02:02 |
+----------------------------------------+--------------------------------+
1 row in set (0.00 sec)
mysql> select datediff('2010-12-31 23:59:59','2010-12-30');
+----------------------------------------------+
| datediff('2010-12-31 23:59:59','2010-12-30') |
+----------------------------------------------+
| 1 |
+----------------------------------------------+
1 row in set (0.00 sec)
mysql> select datediff('2010-12-31 23:59:59','2015-12-30');
+----------------------------------------------+
| datediff('2010-12-31 23:59:59','2015-12-30') |
+----------------------------------------------+
| -1825 |
+----------------------------------------------+
1 row in set (0.00 sec)
mysql> select datediff('2030-12-31 23:59:59','2015-12-30');
+----------------------------------------------+
| datediff('2030-12-31 23:59:59','2015-12-30') |
+----------------------------------------------+
| 5480 |
+----------------------------------------------+
1 row in set (0.00 sec)
mysql> select datediff('2020-12-31 23:59:59','2015-12-30');
+----------------------------------------------+
| datediff('2020-12-31 23:59:59','2015-12-30') |
+----------------------------------------------+
| 1828 |
+----------------------------------------------+
1 row in set (0.00 sec)
mysql> select time_stamp();
ERROR 1305 (42000): FUNCTION time_stamp does not exist
mysql> select date_format('1997-10-04 22:23:00','%W %M %Y');
+-----------------------------------------------+
| date_format('1997-10-04 22:23:00','%W %M %Y') |
+-----------------------------------------------+
| Saturday October 1997 |
+-----------------------------------------------+
1 row in set (0.00 sec)
mysql> select date_format('1997-10-04 22:23:00','%D %y %a %d %m %b %j');
+-----------------------------------------------------------+
| date_format('1997-10-04 22:23:00','%D %y %a %d %m %b %j') |
+-----------------------------------------------------------+
| 4th 97 Sat 04 10 Oct 277 |
+-----------------------------------------------------------+
1 row in set (0.00 sec)
mysql> select date_format(now(),'%H:%i:%s');
+-------------------------------+
| date_format(now(),'%H:%i:%s') |
+-------------------------------+
| 16:18:10 |
+-------------------------------+
1 row in set (0.00 sec)
mysql> select date_format('2000-10-05 22:23:00',GET_FORMAT(DATE,'USA'));
+-----------------------------------------------------------+
| date_format('2000-10-05 22:23:00',GET_FORMAT(DATE,'USA')) |
+-----------------------------------------------------------+
| 10.05.2000 |
+-----------------------------------------------------------+
1 row in set (0.00 sec)
mysql> select date_format(now(),GET_FORMAT(DATE,'USA'));
+-------------------------------------------+
| date_format(now(),GET_FORMAT(DATE,'USA')) |
+-------------------------------------------+
| 09.05.2015 |
+-------------------------------------------+
1 row in set (0.00 sec)
mysql>
mysql 常见函数2
最新推荐文章于 2022-10-19 10:46:09 发布