[英]Select most recent row from another table
我想显示不同表中的最新评论及其日期。 不同的表键控到主表中的行。 换一种说法:
“主”表键控到notes
表。 notes
表可以有任意数量的条目,提供参考main
表行所采取的步骤的详细信息,但我只想在我的查询中显示最近的评论和日期。
主表名是表notes. The 2 columns in
main
键notes. The 2 columns in
I need are
笔记中notes. The 2 columns in
I need are
entry_timestamp and
activity_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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.