Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL查询选择全部并转换日期_Mysql_Date_Timestamp - Fatal编程技术网

MySQL查询选择全部并转换日期

MySQL查询选择全部并转换日期,mysql,date,timestamp,Mysql,Date,Timestamp,我如何在MySQL中编写一个查询,以选择全部并将2个UNIX日期列转换为可读的内容,即从unixtime(received_date)开始,而无需手动写出select语句中的每个其他列名?您可以使用 SELECT *, from_unixtime(received_date), from_unixtime(other_date_field) FROM table; 结果中将以时间戳和可读格式显示两个日期列。您可能希望使用AS重命名可读列,如下所示: SELECT *, from_unixtim

我如何在MySQL中编写一个查询,以选择全部并将2个UNIX日期列转换为可读的内容,即从unixtime(received_date)开始,而无需手动写出select语句中的每个其他列名?

您可以使用

SELECT *, from_unixtime(received_date), from_unixtime(other_date_field) FROM table;
结果中将以时间戳和可读格式显示两个日期列。您可能希望使用AS重命名可读列,如下所示:

SELECT *, from_unixtime(received_date) AS date1, from_unixtime(other_date_field) AS date2 FROM table;
请注意,通配符必须放在第一位:

SELECT *, field FROM...
如果您选择字段,*FROM

我希望这有帮助