user3425900 user3425900 - 6 months ago 10
MySQL Question

How to Convert Epoch Time in a MySql Join

I have a simple mysql query:

SELECT *
FROM User_Info
RIGHT JOIN Log ON User_Info.Key = Log.U_id
LIMIT 0 , 30


Log has a epoch time column that needs to be converted. What's the proper syntax for adding a convert during a join?

Answer

You need to specify the table as table.column.

SELECT *, FROM_UNIXTIME(Log.epoch) AS log_time
FROM User_Info
RIGHT JOIN Log ON User_Info.Key = Log.U_id
LIMIT 0 , 30

Please replace the epoch with the correct field name.