我目前正在尝试构建一个有点棘手的 MySQL Select 语句。这是我想要完成的事情:
我有一张这样的桌子:
data_table
uniqueID stringID subject
1 144 "My Subject"
2 144 "My Subject - New"
3 144 "My Subject - Newest"
4 211 "Some other column"
基本上,我想做的是能够 SELECT/GROUP BY the stringID(stringID 是线程的图片)而不是重复它。此外,我想选择最近的 stringID 行(在上面的示例中是 uniqueID 3)。
因此,如果我要查询数据库,它将返回以下内容(最新的 uniqueID 在顶部):
uniqueID stringID subject
4 211 "Some other column"
3 144 "My Subject - Newest" //Notice this is the most recent and distinct stringID row, with the proper subject column.
我希望这是有道理的。谢谢你的帮助。