FROM_UNIXTIME(unix_timestamp), FROM_UNIXTIME(unix_timestamp,format) Returns a representation of the unix_timestamp argument as a value in 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context. The value is expressed in the current time zone. unix_timestamp is an internal timestamp value such as is produced by the UNIX_TIMESTAMP() function. If format is given, the result is formatted according to the format string, which is used the same way as listed in the entry for the DATE_FORMAT() function. mysql> SELECT FROM_UNIXTIME(875996580); -> '1997-10-04 22:23:00' mysql> SELECT FROM_UNIXTIME(875996580) + 0; -> 19971004222300 mysql> SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(), -> '%Y %D %M %h:%i:%s %x'); -> '2003 6th August 06:22:58 2003'Note: If you use UNIX_TIMESTAMP() and FROM_UNIXTIME() to convert between TIMESTAMP values and Unix timestamp values, the conversion is lossy because the mapping is not one-to-one in both directions. For details, see the description of the UNIX_TIMESTAMP() function.
但是它提示我说:ERROR 1248 (42000):Every derived table must have its own alias
我按你的代码输入进去后,也注意到了是(`time`)..但是它提示我说 ERROR 1248 (42000):Every derived table must have its own alias
select * from a
union all
select * from b) order by FROM_UNIXTIME(`time`) desc
union all
select * from b
order by time字段 desc
select * from a
union all
select * from b) aa order by FROM_UNIXTIME(`time`) desc打开此记录集循环
想问一下..这个FROM_UNIXTIME('time')是什么意思?.我放到MySQL里执行它提示错误.是不是要在程序里执行?
FROM_UNIXTIME(`time`)
哦.我懂了..这个是格式化timestamp..不过我还不需要这样.我只用对时间戳排序就够了..谢了~
-> '1997-10-04 22:23:00'
mysql> SELECT FROM_UNIXTIME(875996580) + 0;
-> 19971004222300
mysql> SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(),
-> '%Y %D %M %h:%i:%s %x');
-> '2003 6th August 06:22:58 2003'Note: If you use UNIX_TIMESTAMP() and FROM_UNIXTIME() to convert between TIMESTAMP values and Unix timestamp values, the conversion is lossy because the mapping is not one-to-one in both directions. For details, see the description of the UNIX_TIMESTAMP() function.
我按你的代码输入进去后,也注意到了是(`time`)..但是它提示我说
ERROR 1248 (42000):Every derived table must have its own alias