gpt4 book ai didi

mysql - 从另一个表中选择最新行

转载 作者:行者123 更新时间:2023-11-29 14:36:52 26 4
gpt4 key购买 nike

我想显示另一个表中的最新评论及其日期。不同的表以主表中的行为键。另一种说法是:

“主”表是 notes 表的关键。 notes 表可以包含任意数量的条目,提供引用 main 表行所采取的步骤的详细信息,但我只想在查询中显示最新的评论和日期.

主表名称是main,键控到表注释。我需要的 notes 中的两列是 entry_timestampactivity_notes`。

最佳答案

类似的东西

select
(select activity_notes from notes n where n.mainId = m.id order by m.entry_timestamp desc LIMIT 1)
, (select entry_timestamp from notes n where n.mainId = m.id order by m.entry_timestamp desc LIMIT 1)
from main m

关于mysql - 从另一个表中选择最新行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8844167/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com