hapiman / jsrice

A common utils using in javascript
0 stars 0 forks source link

sql相关语句 #19

Open hapiman opened 7 years ago

hapiman commented 7 years ago
ALTER TABLE promote_idfa
add COLUMN impId VARCHAR(255) COMMENT 'impId';

ALTER TABLE promote_idfa
add COLUMN ua VARCHAR(255) COMMENT 'ua';
hapiman commented 7 years ago

获取当前时间戳 select unix_timestamp(); 获取指定时间的时间戳 select unix_timestamp('2013-01-01 10:10:10');

将时间戳转化成日期 select from_unixtime(1355272360); => 2012-12-12 08:32:40 将时间戳转化成日期,指定格式 select from_unixtime(1355272360,'%Y%m%d');

hapiman commented 7 years ago

mysql处理四舍五入 SELECT FORMAT(12332.123456, 4); => 12,332.1235 会直接将数据加上‘,’ 如果不需要 则需要 select convert(4545.1366,decimal);这样处理