我使用的是另一个Stackoverflow用户提供帮助的以下查询,这对我来说是全新的:

"SELECT CONCAT(u1.firstname,' ',u1.lastname) as sender,CONCAT(u2.firstname,'
',u2.lastname) as receiver, t.points as points FROM transactions t INNER JOIN users u1 ON
u1.id=t.sender_id INNER JOIN users u2 ON u2.id=t.receiver_id ORDER BY date DESC limit 5"


它工作正常,但我意识到我没有从数据库中获得值'timestamp'。如何在查询中添加timestamp,以便在结果中回显?

'timestamp'存储在transactions表中。

谢谢。

最佳答案

您只需在查询中添加t.timestamp

"SELECT CONCAT(u1.firstname,' ',u1.lastname) as sender,CONCAT(u2.firstname,'
',u2.lastname) as receiver, t.points as points, t.timestamp FROM transactions t INNER JOIN users u1 ON
u1.id=t.sender_id INNER JOIN users u2 ON u2.id=t.receiver_id ORDER BY date DESC limit 5"

关于php - 如何修改此PHP查询以添加数据库值“时间戳”?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25698801/

10-11 03:03