diff --git a/phpbb/rusefi/web/service/utils.php b/phpbb/rusefi/web/service/utils.php index 190c387..275c9e8 100644 --- a/phpbb/rusefi/web/service/utils.php +++ b/phpbb/rusefi/web/service/utils.php @@ -74,9 +74,9 @@ class utils } public function get_engines($user_id) { - $sql = 'SELECT m.file AS id, e.make AS make, e.code AS code FROM msqur_metadata m '. - 'JOIN (SELECT id,name,make,code FROM msqur_engines WHERE user_id = ' . (int) $user_id . ') e '. - 'WHERE m.engine = e.id GROUP BY e.name ORDER BY m.file DESC'; + $sql = 'SELECT MAX(m.file) AS id, e.make AS make, e.code AS code FROM msqur_engines e ' . + 'INNER JOIN msqur_metadata m ON m.engine = e.id WHERE (user_id = ' . (int) $user_id . ') '. + 'GROUP BY e.name'; $result = $this->db->sql_query($sql); $output = array();