SELECT id, upload_date, user_fullname, user_id, title, avg_rate, rate_count, img_subject, img_material, avatar_path, materials_RU AS material, img_material as material_id, img_year, price, comment, section_RU AS section, section_id, genres_RU as genre, genres_id, style_RU AS style, style_id, width, height, availability_RU AS availability, availability_id, img_ratio, technique_id, technique_RU AS technique, path_small, path_medium, img_true, view_in_virt_room, comment_ban, code, img_sensored, img_add_date, username, block, title_en FROM (SELECT as id, upload_date, user_fullname_ru AS user_fullname, user_id, title_RU AS title, ROUND(AVG(rate),1) AS avg_rate, COUNT(rate) AS rate_count, img_subject_RU as img_subject, img_material, img_year, img_price_value as price, img_comment_with_work_RU as comment, section_id, genres_id, style_id, img_real_width AS width, img_real_height AS height, availability_id, img_ratio, technique_id, path_small, path_medium, img_true, comment_ban, code, img_sensored, username, block, title AS title_en FROM images, users, image_rating, system_countries WHERE AND users.user_id=owner AND users.country_id = AND img_id=1132 LIMIT 1 )q LEFT JOIN users_avatars USING(user_id) LEFT JOIN image_materials ON materials_id=img_material LEFT JOIN image_sections USING(section_id) LEFT JOIN image_genres USING(genres_id) LEFT JOIN image_styles USING(style_id) LEFT JOIN image_availability USING(availability_id) LEFT JOIN image_technique USING(technique_id) LEFT JOIN image_additional_data ON id = img_id