SELECT `p`.`id`, `p`.currency_id, `p`.`bg_title` AS productTitle, `p`.`bg_text` AS productText, `p`.`new`,
`t`.`id` AS typeId, `t`.`bg_title` AS typeTitle, `v`.`id` AS vidId, `v`.`bg_title` as vidTitle, `p`.`shum` as shum, `p`.`info_url` as infoUrl,
ROUND ( IF ( `p`.`dds` = 1, `p`.`price`, `p`.`price` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ) AS price,
ROUND ( IF ( `p`.`dds` = 1, `p`.`pprice`, `p`.`pprice` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ) AS pprice,
IF( `p`.`pprice` > 0, ROUND ( IF ( `p`.`dds` = 1, `p`.`pprice`, `p`.`pprice` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ), ROUND ( IF ( `p`.`dds` = 1, `p`.`price`, `p`.`price` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ) ) AS real_price,
`p`.`dds`, `p`.`nalichnost`, `p`.`diameter`, `p`.`width`, `p`.`height`, `p`.`t_index`, `p`.`s_index`, `p`.`rft`, `p`.`shum`,
`p`.`shum_db`, `p`.`povedenie_mokro`, `p`.`sypr_tyrk`,
`p`.`bg_seotitle` as title, `p`.`bg_seodesc` as descr, `p`.`bg_seokeywords` as keyw,
`b`.`id` AS brandId, `b`.`bg_title` AS brandTitle, `b`.`image` AS brandImage,
`i`.`image` AS modelImage,
CASE
WHEN `p`.`shum_db` > 0 AND `p`.`shum_db` <= (SELECT IF( `t`.`id` = 2, `limit_value_ms`, `limit_value` ) - 3 + IF( `v`.`id` IN ( 1, 2 ), 0, 2 ) AS limit_value FROM `g_noises` WHERE CONVERT( `p`.`width`, UNSIGNED ) >= `min_width` AND CONVERT( `p`.`width`, UNSIGNED ) <= `max_width` LIMIT 1)
THEN 1
WHEN `p`.`shum_db` > (SELECT IF( `t`.`id` = 2, `limit_value_ms`, `limit_value` ) - 3 + IF( `v`.`id` IN ( 1, 2 ), 0, 2 ) AS limit_value FROM `g_noises` WHERE CONVERT( `p`.`width`, UNSIGNED ) >= `min_width` AND CONVERT( `p`.`width`, UNSIGNED ) <= `max_width` LIMIT 1) AND
`p`.`shum_db` <= (SELECT IF( `t`.`id` = 2, `limit_value_ms`, `limit_value` ) + IF( `v`.`id` IN ( 1, 2 ), 0, 2 ) AS limit_value FROM `g_noises` WHERE CONVERT( `p`.`width`, UNSIGNED ) >= `min_width` AND CONVERT( `p`.`width`, UNSIGNED ) <= `max_width` LIMIT 1)
THEN 2
WHEN `p`.`shum_db` > (SELECT IF( `t`.`id` = 2, `limit_value_ms`, `limit_value` ) + IF( `v`.`id` IN ( 1, 2 ), 0, 2 ) AS limit_value FROM `g_noises` WHERE CONVERT( `p`.`width`, UNSIGNED ) >= `min_width` AND CONVERT( `p`.`width`, UNSIGNED ) <= `max_width` LIMIT 1)
THEN 3
ELSE 0
END AS noise,
(SELECT IFNULL(AVG(`rating`), 0) FROM `g_opinions` WHERE `product_id` = `p`.`id` AND `bg_title` <> '' AND `mail` <> '' AND `rating` > 0) AS rating,
(SELECT COUNT(`id`) FROM `g_opinions` WHERE `product_id` = `p`.`id` AND `bg_title` <> '' AND `mail` <> '') AS reviews
FROM `g_products` AS p LEFT JOIN `g_brands` AS b ON `p`.`brand_id` = `b`.`id`
LEFT JOIN `g_types` AS t ON `p`.`type_id` = `t`.`id`
LEFT JOIN `g_vidove` AS v ON `p`.`vid_id` = `v`.`id`
LEFT JOIN `g_models_image` AS i ON `p`.`bg_title` = `i`.`model` AND `p`.`brand_id` = `i`.`brand_id`
WHERE `p`.`active` = 1 AND `p`.`enabled` = 1 AND `p`.`status` = 1 AND p.nalichnost > 1 AND `b`.`active` = 1
AND `v`.`active` = 1 AND `v`.`enabled` = 1
AND `b`.`enabled` = 1 AND `t`.`enabled` = 1 AND `t`.`active` = 1
AND IF( `p`.`pprice` > 0, ROUND ( IF ( `p`.`dds` = 1, `p`.`pprice`, `p`.`pprice` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ), ROUND ( IF ( `p`.`dds` = 1, `p`.`price`, `p`.`price` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ) ) > 0
AND `p`.`id` = 94431
SELECT `p`.`id`, `p`.currency_id, `p`.`bg_title` AS productTitle, `p`.`bg_text` AS productText, `p`.`new`,
`t`.`id` AS typeId, `t`.`bg_title` AS typeTitle, `v`.`id` AS vidId, `v`.`bg_title` as vidTitle, `p`.`shum` as shum, `p`.`info_url` as infoUrl,
ROUND ( IF ( `p`.`dds` = 1, `p`.`price`, `p`.`price` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ) AS price,
ROUND ( IF ( `p`.`dds` = 1, `p`.`pprice`, `p`.`pprice` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ) AS pprice,
IF( `p`.`pprice` > 0, ROUND ( IF ( `p`.`dds` = 1, `p`.`pprice`, `p`.`pprice` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ), ROUND ( IF ( `p`.`dds` = 1, `p`.`price`, `p`.`price` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ) ) AS real_price,
`p`.`dds`, `p`.`nalichnost`, `p`.`diameter`, `p`.`width`, `p`.`height`, `p`.`t_index`, `p`.`s_index`, `p`.`rft`, `p`.`shum`,
`p`.`shum_db`, `p`.`povedenie_mokro`, `p`.`sypr_tyrk`,
`p`.`bg_seotitle` as title, `p`.`bg_seodesc` as descr, `p`.`bg_seokeywords` as keyw,
`b`.`id` AS brandId, `b`.`bg_title` AS brandTitle, `b`.`image` AS brandImage,
`i`.`image` AS modelImage,
CASE
WHEN `p`.`shum_db` > 0 AND `p`.`shum_db` <= (SELECT IF( `t`.`id` = 2, `limit_value_ms`, `limit_value` ) - 3 + IF( `v`.`id` IN ( 1, 2 ), 0, 2 ) AS limit_value FROM `g_noises` WHERE CONVERT( `p`.`width`, UNSIGNED ) >= `min_width` AND CONVERT( `p`.`width`, UNSIGNED ) <= `max_width` LIMIT 1)
THEN 1
WHEN `p`.`shum_db` > (SELECT IF( `t`.`id` = 2, `limit_value_ms`, `limit_value` ) - 3 + IF( `v`.`id` IN ( 1, 2 ), 0, 2 ) AS limit_value FROM `g_noises` WHERE CONVERT( `p`.`width`, UNSIGNED ) >= `min_width` AND CONVERT( `p`.`width`, UNSIGNED ) <= `max_width` LIMIT 1) AND
`p`.`shum_db` <= (SELECT IF( `t`.`id` = 2, `limit_value_ms`, `limit_value` ) + IF( `v`.`id` IN ( 1, 2 ), 0, 2 ) AS limit_value FROM `g_noises` WHERE CONVERT( `p`.`width`, UNSIGNED ) >= `min_width` AND CONVERT( `p`.`width`, UNSIGNED ) <= `max_width` LIMIT 1)
THEN 2
WHEN `p`.`shum_db` > (SELECT IF( `t`.`id` = 2, `limit_value_ms`, `limit_value` ) + IF( `v`.`id` IN ( 1, 2 ), 0, 2 ) AS limit_value FROM `g_noises` WHERE CONVERT( `p`.`width`, UNSIGNED ) >= `min_width` AND CONVERT( `p`.`width`, UNSIGNED ) <= `max_width` LIMIT 1)
THEN 3
ELSE 0
END AS noise,
(SELECT IFNULL(AVG(`rating`), 0) FROM `g_opinions` WHERE `product_id` = `p`.`id` AND `bg_title` <> '' AND `mail` <> '' AND `rating` > 0) AS rating,
(SELECT COUNT(`id`) FROM `g_opinions` WHERE `product_id` = `p`.`id` AND `bg_title` <> '' AND `mail` <> '') AS reviews
FROM `g_products` AS p LEFT JOIN `g_brands` AS b ON `p`.`brand_id` = `b`.`id`
LEFT JOIN `g_types` AS t ON `p`.`type_id` = `t`.`id`
LEFT JOIN `g_vidove` AS v ON `p`.`vid_id` = `v`.`id`
LEFT JOIN `g_models_image` AS i ON `p`.`bg_title` = `i`.`model` AND `p`.`brand_id` = `i`.`brand_id`
WHERE `p`.`active` = 1 AND `p`.`enabled` = 1 AND `p`.`status` = 1 AND p.nalichnost > 1 AND `b`.`active` = 1
AND `v`.`active` = 1 AND `v`.`enabled` = 1
AND `b`.`enabled` = 1 AND `t`.`enabled` = 1 AND `t`.`active` = 1
AND IF( `p`.`pprice` > 0, ROUND ( IF ( `p`.`dds` = 1, `p`.`pprice`, `p`.`pprice` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ), ROUND ( IF ( `p`.`dds` = 1, `p`.`price`, `p`.`price` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ) ) > 0
AND `p`.`id` = 94431
SELECT `p`.`id`, `p`.currency_id, `p`.`bg_title` AS productTitle, `p`.`bg_text` AS productText, `p`.`new`,
`t`.`id` AS typeId, `t`.`bg_title` AS typeTitle, `v`.`id` AS vidId, `v`.`bg_title` as vidTitle, `p`.`shum` as shum, `p`.`info_url` as infoUrl,
ROUND ( IF ( `p`.`dds` = 1, `p`.`price`, `p`.`price` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ) AS price,
ROUND ( IF ( `p`.`dds` = 1, `p`.`pprice`, `p`.`pprice` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ) AS pprice,
IF( `p`.`pprice` > 0, ROUND ( IF ( `p`.`dds` = 1, `p`.`pprice`, `p`.`pprice` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ), ROUND ( IF ( `p`.`dds` = 1, `p`.`price`, `p`.`price` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ) ) AS real_price,
`p`.`dds`, `p`.`nalichnost`, `p`.`diameter`, `p`.`width`, `p`.`height`, `p`.`t_index`, `p`.`s_index`, `p`.`rft`, `p`.`shum`,
`p`.`shum_db`, `p`.`povedenie_mokro`, `p`.`sypr_tyrk`,
`p`.`bg_seotitle` as title, `p`.`bg_seodesc` as descr, `p`.`bg_seokeywords` as keyw,
`b`.`id` AS brandId, `b`.`bg_title` AS brandTitle, `b`.`image` AS brandImage,
`i`.`image` AS modelImage,
CASE
WHEN `p`.`shum_db` > 0 AND `p`.`shum_db` <= (SELECT IF( `t`.`id` = 2, `limit_value_ms`, `limit_value` ) - 3 + IF( `v`.`id` IN ( 1, 2 ), 0, 2 ) AS limit_value FROM `g_noises` WHERE CONVERT( `p`.`width`, UNSIGNED ) >= `min_width` AND CONVERT( `p`.`width`, UNSIGNED ) <= `max_width` LIMIT 1)
THEN 1
WHEN `p`.`shum_db` > (SELECT IF( `t`.`id` = 2, `limit_value_ms`, `limit_value` ) - 3 + IF( `v`.`id` IN ( 1, 2 ), 0, 2 ) AS limit_value FROM `g_noises` WHERE CONVERT( `p`.`width`, UNSIGNED ) >= `min_width` AND CONVERT( `p`.`width`, UNSIGNED ) <= `max_width` LIMIT 1) AND
`p`.`shum_db` <= (SELECT IF( `t`.`id` = 2, `limit_value_ms`, `limit_value` ) + IF( `v`.`id` IN ( 1, 2 ), 0, 2 ) AS limit_value FROM `g_noises` WHERE CONVERT( `p`.`width`, UNSIGNED ) >= `min_width` AND CONVERT( `p`.`width`, UNSIGNED ) <= `max_width` LIMIT 1)
THEN 2
WHEN `p`.`shum_db` > (SELECT IF( `t`.`id` = 2, `limit_value_ms`, `limit_value` ) + IF( `v`.`id` IN ( 1, 2 ), 0, 2 ) AS limit_value FROM `g_noises` WHERE CONVERT( `p`.`width`, UNSIGNED ) >= `min_width` AND CONVERT( `p`.`width`, UNSIGNED ) <= `max_width` LIMIT 1)
THEN 3
ELSE 0
END AS noise,
(SELECT IFNULL(AVG(`rating`), 0) FROM `g_opinions` WHERE `product_id` = `p`.`id` AND `bg_title` <> '' AND `mail` <> '' AND `rating` > 0) AS rating,
(SELECT COUNT(`id`) FROM `g_opinions` WHERE `product_id` = `p`.`id` AND `bg_title` <> '' AND `mail` <> '') AS reviews
FROM `g_products` AS p LEFT JOIN `g_brands` AS b ON `p`.`brand_id` = `b`.`id`
LEFT JOIN `g_types` AS t ON `p`.`type_id` = `t`.`id`
LEFT JOIN `g_vidove` AS v ON `p`.`vid_id` = `v`.`id`
LEFT JOIN `g_models_image` AS i ON `p`.`bg_title` = `i`.`model` AND `p`.`brand_id` = `i`.`brand_id`
WHERE `p`.`active` = 1 AND `p`.`enabled` = 1 AND `p`.`status` = 1 AND p.nalichnost > 1 AND `b`.`active` = 1
AND `v`.`active` = 1 AND `v`.`enabled` = 1
AND `b`.`enabled` = 1 AND `t`.`enabled` = 1 AND `t`.`active` = 1
AND IF( `p`.`pprice` > 0, ROUND ( IF ( `p`.`dds` = 1, `p`.`pprice`, `p`.`pprice` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ), ROUND ( IF ( `p`.`dds` = 1, `p`.`price`, `p`.`price` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ) ) > 0
AND `p`.`id` = 94431
SELECT `p`.`id`, `p`.currency_id, `p`.`bg_title` AS productTitle, `p`.`bg_text` AS productText, `p`.`new`,
`t`.`id` AS typeId, `t`.`bg_title` AS typeTitle, `v`.`id` AS vidId, `v`.`bg_title` as vidTitle, `p`.`shum` as shum, `p`.`info_url` as infoUrl,
ROUND ( IF ( `p`.`dds` = 1, `p`.`price`, `p`.`price` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ) AS price,
ROUND ( IF ( `p`.`dds` = 1, `p`.`pprice`, `p`.`pprice` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ) AS pprice,
IF( `p`.`pprice` > 0, ROUND ( IF ( `p`.`dds` = 1, `p`.`pprice`, `p`.`pprice` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ), ROUND ( IF ( `p`.`dds` = 1, `p`.`price`, `p`.`price` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ) ) AS real_price,
`p`.`dds`, `p`.`nalichnost`, `p`.`diameter`, `p`.`width`, `p`.`height`, `p`.`t_index`, `p`.`s_index`, `p`.`rft`, `p`.`shum`,
`p`.`shum_db`, `p`.`povedenie_mokro`, `p`.`sypr_tyrk`,
`p`.`bg_seotitle` as title, `p`.`bg_seodesc` as descr, `p`.`bg_seokeywords` as keyw,
`b`.`id` AS brandId, `b`.`bg_title` AS brandTitle, `b`.`image` AS brandImage,
`i`.`image` AS modelImage,
CASE
WHEN `p`.`shum_db` > 0 AND `p`.`shum_db` <= (SELECT IF( `t`.`id` = 2, `limit_value_ms`, `limit_value` ) - 3 + IF( `v`.`id` IN ( 1, 2 ), 0, 2 ) AS limit_value FROM `g_noises` WHERE CONVERT( `p`.`width`, UNSIGNED ) >= `min_width` AND CONVERT( `p`.`width`, UNSIGNED ) <= `max_width` LIMIT 1)
THEN 1
WHEN `p`.`shum_db` > (SELECT IF( `t`.`id` = 2, `limit_value_ms`, `limit_value` ) - 3 + IF( `v`.`id` IN ( 1, 2 ), 0, 2 ) AS limit_value FROM `g_noises` WHERE CONVERT( `p`.`width`, UNSIGNED ) >= `min_width` AND CONVERT( `p`.`width`, UNSIGNED ) <= `max_width` LIMIT 1) AND
`p`.`shum_db` <= (SELECT IF( `t`.`id` = 2, `limit_value_ms`, `limit_value` ) + IF( `v`.`id` IN ( 1, 2 ), 0, 2 ) AS limit_value FROM `g_noises` WHERE CONVERT( `p`.`width`, UNSIGNED ) >= `min_width` AND CONVERT( `p`.`width`, UNSIGNED ) <= `max_width` LIMIT 1)
THEN 2
WHEN `p`.`shum_db` > (SELECT IF( `t`.`id` = 2, `limit_value_ms`, `limit_value` ) + IF( `v`.`id` IN ( 1, 2 ), 0, 2 ) AS limit_value FROM `g_noises` WHERE CONVERT( `p`.`width`, UNSIGNED ) >= `min_width` AND CONVERT( `p`.`width`, UNSIGNED ) <= `max_width` LIMIT 1)
THEN 3
ELSE 0
END AS noise,
(SELECT IFNULL(AVG(`rating`), 0) FROM `g_opinions` WHERE `product_id` = `p`.`id` AND `bg_title` <> '' AND `mail` <> '' AND `rating` > 0) AS rating,
(SELECT COUNT(`id`) FROM `g_opinions` WHERE `product_id` = `p`.`id` AND `bg_title` <> '' AND `mail` <> '') AS reviews
FROM `g_products` AS p LEFT JOIN `g_brands` AS b ON `p`.`brand_id` = `b`.`id`
LEFT JOIN `g_types` AS t ON `p`.`type_id` = `t`.`id`
LEFT JOIN `g_vidove` AS v ON `p`.`vid_id` = `v`.`id`
LEFT JOIN `g_models_image` AS i ON `p`.`bg_title` = `i`.`model` AND `p`.`brand_id` = `i`.`brand_id`
WHERE `p`.`active` = 1 AND `p`.`enabled` = 1 AND `p`.`status` = 1 AND p.nalichnost > 1 AND `b`.`active` = 1
AND `v`.`active` = 1 AND `v`.`enabled` = 1
AND `b`.`enabled` = 1 AND `t`.`enabled` = 1 AND `t`.`active` = 1
AND IF( `p`.`pprice` > 0, ROUND ( IF ( `p`.`dds` = 1, `p`.`pprice`, `p`.`pprice` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ), ROUND ( IF ( `p`.`dds` = 1, `p`.`price`, `p`.`price` * 1.2 ) * ( SELECT IF ( `b`.`charge` = 0, 1, 1 + ( `b`.`charge` / 100 ) ) FROM `g_brands` WHERE `g_brands`.`id` = `p`.`brand_id` ) / 100, 2 ) ) > 0
AND `p`.`id` = 94431