我试图将下面查询的内部子查询转换为显式 JOIN
。
SELECT *
FROM `files`
WHERE `version` = (
SELECT `temp`.`version`
FROM `files` AS `temp`
WHERE `temp`.`location` = `files`.`location`
AND temp.name = `files`.name
ORDER BY `temp`.`version` DESC
LIMIT 1
)
ORDER BY `location`, `name`
我尝试了以下操作,但最终得到的结果集不正确:
SELECT *
FROM `files`
WHERE `version` = (
SELECT `temp`.`version`
FROM `files` AS `temp`
JOIN files ON `temp`.`location` = `files`.`location` AND temp.name = `files`.name
ORDER BY `temp`.`version` DESC
LIMIT 1
)
ORDER BY `location`, `name`
我如何在SQLite中执行此操作?