gpt4 book ai didi

sqlite,在连接表中按日期/整数排序

转载 作者:行者123 更新时间:2023-12-03 19:37:21 25 4
gpt4 key购买 nike

我有两张 table

名称

id | name
---------
5 | bill
15 | bob
10 | nancy

参赛作品
id | name_id | added    | description
----------------------------------
2 | 5 | 20140908 | i added this
4 | 5 | 20140910 | added later on
9 | 10 | 20140908 | i also added this
1 | 15 | 20140805 | added early on
6 | 5 | 20141015 | late to the party

我要订购 Names由数字最低的第一个 added Entries 中的值表,并显示两个表中按 added 排序的行列整体,因此结果将类似于:
names.id | names.name | entries.added | entries.description
-----------------------------------------------------------
15 | bob | 20140805 | added early on
5 | bill | 20140908 | i added this
10 | nancy | 20140908 | i also added this

我查看了第一项的联接(例如 SQL Server: How to Join to first row ),但无法使其正常工作。

有小费吗?

最佳答案

试试这个查询:

SELECT Names.id, Names.name, Entries.added, Entries.description 
FROM Names
INNER JOIN Entries
ON Names.id = Entries.name_id
ORDER BY Entries.added

添加 DESC如果你想要它以相反的顺序,即: ORDER BY Entries.added DESC .

关于sqlite,在连接表中按日期/整数排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33064823/

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