我正在运行以下 SQL 查询:
SELECT * FROM cms_albums WHERE id IN (SELECT album_id FROM cms_albums_collections WHERE collection_id = 1 ORDER BY position ASC)
现在,假设内部查询
SELECT album_id FROM cms_albums_collections WHERE collection_id = 1 ORDER BY position ASC
返回以下内容:
album_id
"4"
"2"
这是我想要的顺序。但是,整体查询将返回:
id name
"2" "Second album"
"4" "First album"
我假设这是因为条目在“cms_albums”表中按此顺序排列。有什么方法可以按照内部查询给出的顺序得到我的整体结果?
谢谢