[英]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.