mysql-获取当前系统时间

1.获取当前日期+时间
now();
sysdate();

这两个函数都是获取日期+时间,不同之处在于:now()在执行开始时值就得到了,sysdate()在函数执行时动态得到值

2.获取当前日期:
curdate();
current_date();
current_date;
3.获取当前时间:
curtime();
current_time();
current_time;

4.获取UTC时间
A.获取UTC日期:utc_date();
B.获取UTC时间:utc_time();
C.获取UTC日期+时间:utc_timestamp;


MySQL写子查询的时候,报错:Every derived table must have its own alias(每个派生表必须有自己的别名),在后面加上个别名就可以解决
错误:select * from (select a.id,a.name from user a union select b.id,b.name from user_old b)
解决:select * from (select a.id,a.name from user a union select b.id,b.name from user_old b) tmp
order by id

你可能感兴趣的:(mysql-获取当前系统时间)