Ошибка SQL: Illegal mix of collations (latin1_swedish_ci,NUMERIC) and (cp1251_general_ci,COERCIBLE) for operation 'regexp_substr'
SQL: [SELECT /* 926,494172 */ COALESCE(a.boat_ref_link, a.boat_uid_id) AS boat_uid_id,
a.boat_cnt_account AS boat_cnt_account,
a.boat_hld_holder AS boat_hld_holder,
a.boat_mbr_member AS boat_mbr_member,
a.boat_lng_language AS boat_lng_language,
a.boat_ref_link AS boat_ref_link,
a.boat_chr_link AS boat_chr_link,
@boatName := IF(a.boat_hld_holder = 5531, a.boat_chr_name, COALESCE(NULLIF(a.boat_chr_name2, ''), NULLIF(a.boat_chr_name, ''), a.boat_set_builder)) AS boat_chr_name,
COALESCE(b.boat_chr_nick,a.boat_chr_nick) AS boat_chr_nick,
a.boat_chr_article AS boat_chr_article,
COALESCE(NULLIF(COALESCE(b.boat_chr_nick,a.boat_chr_nick), ''), @boatName) AS boat_chr_nickorname,
COALESCE(NULLIF(@boatName, ''), COALESCE(b.boat_chr_nick,a.boat_chr_nick)) AS boat_chr_nameornick,
@naming := CONCAT_WS(', ', IFNULL(CONVERT(@boatName USING cp1251), ''), IFNULL(COALESCE(b.boat_chr_nick,a.boat_chr_nick), '')) AS boat_chr_naming,
COALESCE(a.boat_img_image4, a.boat_img_image, a.boat_img_image5) AS boat_img_image,
a.boat_int_length AS boat_int_length,
a.boat_int_length2 AS boat_int_length2,
a.boat_int_length3 AS boat_int_length3,
a.boat_int_breadth AS boat_int_breadth,
a.boat_int_breadth2 AS boat_int_breadth2,
a.boat_int_depth AS boat_int_depth,
a.boat_int_draft AS boat_int_draft,
a.boat_int_draft2 AS boat_int_draft2,
a.boat_int_waterline AS boat_int_waterline,
COALESCE(b.boat_set_keel,a.boat_set_keel) AS boat_set_keel,
a.boat_int_displacement AS boat_int_displacement,
a.boat_int_displacement2 AS boat_int_displacement2,
a.boat_int_water AS boat_int_water,
a.boat_int_fuel AS boat_int_fuel,
a.boat_int_tank AS boat_int_tank,
a.boat_int_tank2 AS boat_int_tank2,
a.boat_int_tank3 AS boat_int_tank3,
a.boat_int_speed AS boat_int_speed,
a.boat_int_maxspeed AS boat_int_maxspeed,
ROUND(a.boat_int_range, 0) AS boat_int_range,
a.boat_chr_tonnage AS boat_chr_tonnage,
COALESCE(b.boat_set_engine,a.boat_set_engine) AS boat_set_engine,
COALESCE(b.boat_set_material,a.boat_set_material) AS boat_set_material,
COALESCE(b.boat_set_exterior,a.boat_set_exterior) AS boat_set_exterior,
COALESCE(b.boat_set_interior,a.boat_set_interior) AS boat_set_interior,
COALESCE(b.boat_set_concept,a.boat_set_concept) AS boat_set_concept,
a.boat_int_passenger AS boat_int_passenger,
COALESCE(b.boat_set_cabines,a.boat_set_cabines) AS boat_set_cabines,
help_value.boat_set_valcabines AS boat_set_valcabines,
COALESCE(b.boat_set_berths,a.boat_set_berths) AS boat_set_berths,
COALESCE(b.boat_set_wc,a.boat_set_wc) AS boat_set_wc,
COALESCE(b.boat_set_country,a.boat_set_country) AS boat_set_country,
COALESCE(b.boat_txt_text,a.boat_txt_text) AS boat_txt_text,
COALESCE(b.boat_txt_amenities,a.boat_txt_amenities) AS boat_txt_amenities,
COALESCE(b.boat_txt_amenities2,a.boat_txt_amenities2) AS boat_txt_amenities2,
COALESCE(b.boat_txt_amenities3,a.boat_txt_amenities3) AS boat_txt_amenities3,
COALESCE(b.boat_txt_toys,a.boat_txt_toys) AS boat_txt_toys,
COALESCE(b.boat_txt_toys2,a.boat_txt_toys2) AS boat_txt_toys2,
COALESCE(b.boat_txt_toys3,a.boat_txt_toys3) AS boat_txt_toys3,
COALESCE(NULLIF(COALESCE(b.boat_txt_amenities3,a.boat_txt_amenities3), ''), NULLIF(COALESCE(b.boat_txt_amenities,a.boat_txt_amenities), '')) AS boat_txt_amenities_ankor,
COALESCE(NULLIF(COALESCE(b.boat_txt_amenities3,a.boat_txt_amenities3), ''), NULLIF(COALESCE(b.boat_txt_amenities2,a.boat_txt_amenities2), '')) AS boat_txt_amenities_base,
COALESCE(NULLIF(COALESCE(b.boat_txt_toys3,a.boat_txt_toys3), ''), NULLIF(COALESCE(b.boat_txt_toys,a.boat_txt_toys), '')) AS boat_txt_toys_ankor,
COALESCE(NULLIF(COALESCE(b.boat_txt_toys3,a.boat_txt_toys3), ''), NULLIF(COALESCE(b.boat_txt_toys2,a.boat_txt_toys2), '')) AS boat_txt_toys_base,
@max_length := GREATEST(IFNULL(a.boat_int_length, 0), IFNULL(a.boat_int_length2, 0), IFNULL(a.boat_int_length3, 0)) AS boat_int_maxlength,
GREATEST(IFNULL(a.boat_int_breadth, 0), IFNULL(a.boat_int_breadth2, 0)) AS boat_max_breadth,
@year := (CASE WHEN NULLIF(NULLIF(a.boat_int_year, 0), '') IS NOT NULL AND NULLIF(NULLIF(a.boat_int_month, 0), '') IS NULL THEN a.boat_int_year WHEN NULLIF(NULLIF(a.boat_int_year, 0), '') IS NOT NULL AND NULLIF(NULLIF(a.boat_int_month, 0), '') IS NOT NULL THEN CONCAT_WS('/', (CASE WHEN a.boat_int_month < 4 THEN '1Q' WHEN a.boat_int_month < 7 THEN '2Q' WHEN a.boat_int_month < 10 THEN '3Q' ELSE '4Q' END), a.boat_int_year ) WHEN NULLIF(NULLIF(a.boat_int_year, 0), '') IS NULL AND NULLIF(NULLIF(a.boat_int_timeline, 0), '') IS NOT NULL THEN CONCAT_WS('/', (CASE WHEN DATE_FORMAT(DATE_ADD(NOW(), INTERVAL a.boat_int_timeline MONTH), '%m') < 4 THEN '1Q' WHEN DATE_FORMAT(DATE_ADD(NOW(), INTERVAL a.boat_int_timeline MONTH), '%m') < 7 THEN '2Q' WHEN DATE_FORMAT(DATE_ADD(NOW(), INTERVAL a.boat_int_timeline MONTH), '%m') < 10 THEN '3Q' ELSE '4Q' END), DATE_FORMAT(DATE_ADD(NOW(), INTERVAL a.boat_int_timeline MONTH), '%Y') ) ELSE NULL END) AS boat_int_year,
@year_refit := CONCAT_WS(' / ', CONVERT(IFNULL(@year, 0) USING cp1251), NULLIF(NULLIF(a.boat_int_refit, 0), '')) AS boat_chr_yearrefit,
@net_year := (CASE WHEN NULLIF(NULLIF(a.boat_int_year, 0), '') IS NOT NULL THEN a.boat_int_year WHEN NULLIF(NULLIF(a.boat_int_timeline, 0), '') IS NOT NULL THEN DATE_FORMAT(DATE_ADD(NOW(), INTERVAL a.boat_int_timeline MONTH), '%Y') ELSE NULL END) AS boat_int_netyear,
@nickname := IF(IFNULL(COALESCE(b.boat_chr_nick,a.boat_chr_nick), '') = '', (CASE WHEN a.boat_chk_stock & 16384 AND @max_length >= 25 AND @net_year > YEAR(NOW()) THEN IF(tenders_categories.join_this IS NOT NULL, IF('en' IS NULL, 'Новый катер в постройке', 'New Boat Build'), IF('en' IS NULL, 'Новая яхта в постройке', 'New Yacht Build') ) WHEN a.boat_chk_stock & 16384 AND (@max_length < 25 OR @net_year <= YEAR(NOW())) THEN IF(tenders_categories.join_this IS NOT NULL, IF('en' IS NULL, 'Новый катер', 'New Boat'), IF('en' IS NULL, 'Новая яхта', 'New Yacht') ) ELSE IF('en' IS NULL, 'Имя по запросу', 'Name Please Enquire') END), IF('hatteras-2001-2023-24335' IS NOT NULL, CONCAT_WS(' ', IF(a.boat_hld_holder = 5531, IF(NULLIF(a.boat_enm_type, 'MOTOR') = 'SAIL', 'S/Y', 'M/Y'), (CASE NULLIF(a.boat_enm_type, '') WHEN 'SAIL' THEN 'S/Y' WHEN 'MOTOR' THEN 'M/Y' ELSE NULL END) ), COALESCE(b.boat_chr_nick,a.boat_chr_nick) ), COALESCE(b.boat_chr_nick,a.boat_chr_nick) ) ) AS boat_nickname,
CONCAT_WS(' ', @nickname, IF('en' IS NULL, 'for Charter', 'for Charter')) AS boat_nickname_charter,
@boatCondition := (CASE WHEN a.boat_chk_used & 16384 THEN IF('en' IS NULL, 'Б/У', 'Used') WHEN a.boat_chk_stock & 16384 THEN IF('en' IS NULL, 'Новый', 'New') ELSE NULL END) AS boat_chr_condition,
@nametop := IF(tenders_categories.join_this IS NOT NULL, (CASE WHEN LOCATE( ',1008381,', CONCAT(',', REPLACE(tenders_categories.categories_ids, ' ', ''), ',') ) > 0 THEN IF(NULLIF(@boatCondition, '') IS NOt NULL, CONCAT_WS(' ', @boatCondition, IF('en' IS NULL, 'тендер / риб', 'tender / chase boat')), IF('en' IS NULL, 'Тендер / Риб', 'Tender / Chase boat') ) WHEN LOCATE( ',104895,', CONCAT(',', REPLACE(tenders_categories.categories_ids, ' ', ''), ',') ) > 0 THEN IF(NULLIF(@boatCondition, '') IS NOt NULL, CONCAT_WS(' ', @boatCondition, IF('en' IS NULL, 'рыбацкий катер', 'fishing boat')), IF('en' IS NULL, 'Рыбацкий катер', 'Fishing boat') ) WHEN LOCATE( ',104896,', CONCAT(',', REPLACE(tenders_categories.categories_ids, ' ', ''), ',') ) > 0 THEN IF(NULLIF(@boatCondition, '') IS NOt NULL, CONCAT_WS(' ', @boatCondition, IF('en' IS NULL, 'моторный катер', 'motor boat')), IF('en' IS NULL, 'Моторный катер', 'Motor boat') ) WHEN LOCATE( ',104897,', CONCAT(',', REPLACE(tenders_categories.categories_ids, ' ', ''), ',') ) > 0 THEN IF(NULLIF(@boatCondition, '') IS NOt NULL, CONCAT_WS(' ', @boatCondition, IF('en' IS NULL, 'спортивный катер', 'sport motor boat')), IF('en' IS NULL, 'Спортивный катер', 'Sport motor boat') ) WHEN LOCATE( ',105015,', CONCAT(',', REPLACE(tenders_categories.categories_ids, ' ', ''), ',') ) > 0 THEN IF(NULLIF(@boatCondition, '') IS NOt NULL, CONCAT_WS(' ', @boatCondition, IF('en' IS NULL, 'вейксерф катер', 'wakeboard boat')), IF('en' IS NULL, 'Вейксерф катер', 'Wakeboard boat') ) WHEN LOCATE( ',104898,', CONCAT(',', REPLACE(tenders_categories.categories_ids, ' ', ''), ',') ) > 0 THEN IF(NULLIF(@boatCondition, '') IS NOt NULL, CONCAT_WS(' ', @boatCondition, IF('en' IS NULL, 'круизер', 'cruiser')), IF('en' IS NULL, 'Круизер', 'Cruiser') ) ELSE NULL END), IF(@nickname RLIKE IF('en' IS NULL, 'Имя по запросу', 'Name Please Enquire'), @nickname, IF(a.boat_chk_stock & 16384, @nickname, @boatName) ) ) AS boat_chr_nametop,
IF(tenders_categories.join_this IS NOT NULL, @boatName, IF(@nickname RLIKE IF('en' IS NULL, 'Имя по запросу', 'Name Please Enquire'), @boatName, IF(a.boat_chk_stock & 16384, @boatName, @nickname) ) ) AS boat_chr_namebottom,
IF(a.boat_chk_stock & 16384 AND a.boat_chk_build & 4, CONCAT_WS('', NULLIF(@nametop, ''), IF(NULLIF(NULL, '') IS NULL, ' • ', ' '), CONCAT_WS(' ', IF('en' IS NULL, 'Передача', 'Delivery'), @year) ), @nametop ) AS video_caption_top,
(CASE WHEN a.boat_int_hours = 0 OR a.boat_int_hours IS NULL THEN '' ELSE a.boat_int_hours END) AS boat_int_hours,
@shortMaterial := CONCAT_WS(' & ', CASE WHEN FIND_IN_SET( IF(LOCATE(' | ', a.boat_set_material), SUBSTRING(a.boat_set_material, 1, LOCATE(' | ', a.boat_set_material) - 1), a.boat_set_material), materials.materials_list ) > 0 THEN REGEXP_REPLACE(REGEXP_REPLACE( IF(LOCATE(' | ', a.boat_set_material), SUBSTRING(a.boat_set_material, 1, LOCATE(' | ', a.boat_set_material) - 1), a.boat_set_material), '(?i)Carbon fiber', 'Carbon'), '(?i)Aluminum', 'Alu') ELSE NULL END, CASE WHEN LOCATE(' | ', a.boat_set_material) > 0 AND FIND_IN_SET( SUBSTRING(a.boat_set_material, LOCATE(' | ', a.boat_set_material) + 3), materials.materials_list ) > 0 THEN REGEXP_REPLACE(REGEXP_REPLACE( SUBSTRING(a.boat_set_material, LOCATE(' | ', a.boat_set_material) + 3), '(?i)Carbon fiber', 'Carbon'), '(?i)Aluminum', 'Alu') ELSE NULL END ) AS boat_set_shortmaterial,
CONCAT_WS(' | ', CASE WHEN FIND_IN_SET( IF(LOCATE(' | ', a.boat_set_material), SUBSTRING(a.boat_set_material, 1, LOCATE(' | ', a.boat_set_material) - 1), a.boat_set_material), materials.materials_list ) > 0 THEN IF(LOCATE(' | ', a.boat_set_material), SUBSTRING(a.boat_set_material, 1, LOCATE(' | ', a.boat_set_material) - 1), a.boat_set_material) ELSE NULL END, CASE WHEN LOCATE(' | ', a.boat_set_material) > 0 AND FIND_IN_SET( SUBSTRING(a.boat_set_material, LOCATE(' | ', a.boat_set_material) + 3), materials.materials_list ) > 0 THEN SUBSTRING(a.boat_set_material, LOCATE(' | ', a.boat_set_material) + 3) ELSE NULL END ) AS boat_set_fullmaterial,
IF(tenders_categories.join_this IS NOT NULL, a.boat_int_passenger, @shortMaterial ) AS boat_param4,
IF(tenders_categories.join_this IS NOT NULL, IF(IFNULL(a.boat_int_passenger, 0) <> 0, CONCAT_WS(' ', a.boat_int_passenger, IF('en' IS NULL, 'мест', 'Seats')), NULL ), @shortMaterial ) AS boat_caption_param4,
@yachtTextBase := IFNULL( IF('en' IS NOT NULL, ( SELECT COALESCE(NULLIF(lang.boat_txt_text6, ''), NULLIF(lang.boat_txt_text8, '')) FROM account_boat lang WHERE lang.boat_ref_link = a.boat_uid_id AND lang.boat_lng_language = 'en' ), COALESCE(NULLIF(a.boat_txt_text6, ''), NULLIF(a.boat_txt_text8, '')) ), '' ) AS boat_txt_yachttextbase,
@yachtTextAnkor := IFNULL( COALESCE( NULLIF(CONVERT(@yachtTextBase USING cp1251), ''), IF('en' IS NOT NULL, ( SELECT lang.boat_txt_text FROM account_boat lang WHERE lang.boat_ref_link = a.boat_uid_id AND lang.boat_lng_language = 'en' ), a.boat_txt_text ) ), '' ) AS boat_txt_yachttextankor,
@yachtText := ( CASE WHEN a.boat_hld_holder = 5531 THEN CONVERT(@yachtTextBase USING cp1251) ELSE IF('en' IS NULL AND CONVERT(@yachtTextAnkor USING cp1251) NOT REGEXP '[А-Яа-яЁё]', '', CONVERT(@yachtTextAnkor USING cp1251)) END ) AS boat_txt_yachttext,
IF(get_clean_text(CONVERT(@yachtText USING cp1251)) = '', 'hide', '') AS text_display,
ROUND(IF(a.boat_hld_holder = 5531, a.boat_cur_cost5, COALESCE(NULLIF(a.boat_cur_cost5, 0), a.boat_cur_cost1))) AS boat_dec_costlow,
ROUND(IF(a.boat_hld_holder = 5531, a.boat_cur_cost9, COALESCE(NULLIF(a.boat_cur_cost9, 0), a.boat_cur_cost2))) AS boat_dec_costhigh,
a.boat_cur_cost1 AS boat_cur_cost1,
a.boat_val_cost1 AS boat_val_cost1,
a.boat_cur_cost2 AS boat_cur_cost2,
a.boat_val_cost2 AS boat_val_cost2,
a.boat_cur_cost5 AS boat_cur_cost5,
a.boat_val_cost5 AS boat_val_cost5,
a.boat_cur_cost9 AS boat_cur_cost9,
a.boat_val_cost9 AS boat_val_cost9,
@price := ROUND(IFNULL(IF(help_value.price_field = 'low_season', IF(a.boat_hld_holder = 5531, a.boat_cur_cost5, COALESCE(NULLIF(a.boat_cur_cost5, 0), a.boat_cur_cost1)), IF(a.boat_hld_holder = 5531, a.boat_cur_cost9, COALESCE(NULLIF(a.boat_cur_cost9, 0), a.boat_cur_cost2)) ), 0) ) AS boat_dec_cost,
@valuta := IF(help_value.price_field = 'low_season', IF(a.boat_hld_holder = 5531, a.boat_val_cost5, IF(NULLIF(a.boat_cur_cost5, 0) IS NOT NULL, a.boat_val_cost5, a.boat_val_cost1)), IF(a.boat_hld_holder = 5531, a.boat_val_cost9, IF(NULLIF(a.boat_cur_cost9, 0) IS NOT NULL, a.boat_val_cost9, a.boat_val_cost2)) ) AS val_currency,
(CASE @valuta WHEN 'EUR' THEN '€' WHEN 'USD' THEN '$' WHEN 'RUR' THEN '₽' ELSE '€' END) AS UnitValuta,
(CASE @valuta WHEN 'EUR' THEN 'EUR' WHEN 'USD' THEN 'USD' WHEN 'RUR' THEN 'RUB' ELSE 'EUR' END) AS Valuta,
(CASE IF(a.boat_hld_holder = 5531, a.boat_val_cost5, IF(NULLIF(a.boat_cur_cost5, 0) IS NOT NULL, a.boat_val_cost5, a.boat_val_cost1)) WHEN 'EUR' THEN '€' WHEN 'USD' THEN '$' WHEN 'RUR' THEN '₽' ELSE '€' END) AS UnitValutaLow,
(CASE IF(a.boat_hld_holder = 5531, a.boat_val_cost5, IF(NULLIF(a.boat_cur_cost5, 0) IS NOT NULL, a.boat_val_cost5, a.boat_val_cost1)) WHEN 'EUR' THEN 'EUR' WHEN 'USD' THEN 'USD' WHEN 'RUR' THEN 'RUB' ELSE 'EUR' END) AS ValutaLow,
(CASE IF(a.boat_hld_holder = 5531, a.boat_val_cost9, IF(NULLIF(a.boat_cur_cost9, 0) IS NOT NULL, a.boat_val_cost9, a.boat_val_cost2)) WHEN 'EUR' THEN '€' WHEN 'USD' THEN '$' WHEN 'RUR' THEN '₽' ELSE '€' END) AS UnitValutaHigh,
(CASE IF(a.boat_hld_holder = 5531, a.boat_val_cost9, IF(NULLIF(a.boat_cur_cost9, 0) IS NOT NULL, a.boat_val_cost9, a.boat_val_cost2)) WHEN 'EUR' THEN 'EUR' WHEN 'USD' THEN 'USD' WHEN 'RUR' THEN 'RUB' ELSE 'EUR' END) AS ValutaHigh,
(CASE WHEN a.boat_enm_request = 'YES' THEN (CASE WHEN 'en' IS NULL THEN 'Цена по запросу' ELSE 'Price by Enquire' END) ELSE '' END) AS on_request,
IF(tenders_categories.join_this IS NOT NULL, CONCAT('data-from="', IF('en' IS NULL, 'От', 'From'), '"'), '') AS price_from_caption,
COALESCE(b.boat_set_clear4,a.boat_set_clear4) AS boat_set_clear4,
a.boat_chk_export AS boat_chk_export,
a.boat_chk_build AS boat_chk_build,
brand.list_uid_id AS boat_chr_brandid,
brand.list_chr_name AS boat_chr_brandname,
brand.list_chr_link AS boat_chr_brandlink,
IF(a.boat_uid_id = 17364, a.boat_lnk_master, 126613) AS boat_lnk_manager,
IF(a.boat_uid_id = 17364, a.boat_lnk_master, 126613) AS boat_lnk_master,
a.boat_lnk_shipyard AS boat_lnk_shipyard,
a.boat_set_builder AS boat_set_builder,
IF((a.boat_chk_stock & 32768 OR a.boat_chk_used & 32768), 'boat-charter', 'boat-sale') AS boat_type_class,
( CASE WHEN a.boat_chk_stock & 16384 THEN 'boat-new' WHEN a.boat_chk_used & 16384 THEN 'boat-brokerage' ELSE '' END ) AS boat_status_class,
@soldClass := IF(IFNULL(a.boat_enm_sale,'NO') = 'YES' AND IFNULL(a.boat_enm_reseved,'NO') <> 'YES', 'sold', '') AS sold_class,
@outMarketClass := IF(IFNULL(a.boat_enm_reseved,'NO') = 'YES', 'out-of-market', '') AS out_market_class,
@outProductionClass := IF(IFNULL(a.boat_enm_clear, 'NO') = 'YES', 'out-of-production', '') AS out_production_class,
IF(NOT((NULL & 16384) OR (NULL & 16384)), 'removed', '') AS removed_class,
IF(a.boat_chk_enlarge & 16384, 'top-offer', '') AS offer_class,
IF(tenders_categories.join_this IS NOT NULL, 'tenders', '') AS tenders_class,
IF(tenders_categories.join_this IS NULL, 'hide', '') AS notenders_hide_class,
CONCAT_WS(' | ', CONCAT('', NULLIF(CONVERT(IFNULL(@nickname, '') USING cp1251), ''), ''), IF(CONVERT(CAST(NULLIF(@max_length, 0) AS DECIMAL(10,2)) USING cp1251) IS NOT NULL, CONCAT(CONVERT(CAST(IFNULL(@max_length, 0) AS DECIMAL(10,2)) USING cp1251), IF('en' IS NULL, 'м', 'm')), NULL), NULLIF(CONVERT(IFNULL(@year, 0) USING cp1251), '') ) AS boat_chr_info,
CONCAT_WS(' | ', IF(CONVERT(CAST(NULLIF(@max_length, 0) AS DECIMAL(10,2)) USING cp1251) IS NOT NULL, CONCAT(CONVERT(CAST(IFNULL(@max_length, 0) AS DECIMAL(10,2)) USING cp1251), IF('en' IS NULL, ' М', ' M')), NULL), NULLIF(CONVERT(IFNULL(@year, 0) USING cp1251), ''), NULLIF(COALESCE(b.boat_set_country,a.boat_set_country), ''), IF(a.boat_enm_request <> 'YES' AND CONVERT(@price USING cp1251) <> 0, '', NULL) ) AS boat_chr_headerinfo,
IF(a.boat_chk_build & 2 OR IFNULL(a.boat_enm_flag, 'NO') = 'YES', 'request-popup', '') AS request_popup_class,
'charter' AS boat_type,
IF(IFNULL(a.boat_enm_flag, 'NO') = 'YES' OR a.boat_chk_main & 16384 OR a.boat_chk_enlarge & 16384 OR (a.boat_chk_stock & 16384 AND a.boat_chk_build & 4 AND a.boat_chk_enlarge & 16384), 'badge-yacht', '' ) AS badge_class,
(CASE WHEN IFNULL(a.boat_enm_flag, 'NO') = 'YES' THEN 'badge-confidential' WHEN a.boat_chk_main & 16384 THEN 'badge-exclusive' WHEN (a.boat_chk_stock & 16384 AND a.boat_chk_build & 4 AND a.boat_chk_enlarge & 16384) THEN 'badge-nearest' WHEN a.boat_chk_enlarge & 16384 THEN 'badge-featured' ELSE '' END) AS badge_type_class,
IF((IFNULL(a.boat_enm_sale,'NO') = 'YES' AND IFNULL(a.boat_enm_reseved,'NO') <> 'YES') OR IFNULL(a.boat_enm_reseved,'NO') = 'YES' OR IFNULL(a.boat_enm_clear, 'NO') = 'YES', 1, 0 ) AS boat_sort_irrelevant,
(CASE WHEN a.boat_enm_request = 'YES' OR @price = 0 THEN IF(NULL = '1', 0, 999999999) ELSE IFNULL(ROUND(get_eur_cost(@price, @valuta)), 0) END) AS boat_sort_price,
IF(NULLIF(NULL, '') IS NULL, 1, IFNULL( LOCATE( CONVERT(CONCAT('|', REGEXP_SUBSTR(@naming, get_azimut_combination_regexp(NULL)), '|') USING cp1251), CONVERT(CONCAT('|', get_azimut_combination_regexp(NULL), '|') USING cp1251) ), 999999 ) ) AS boat_sort_search,
IF(a.boat_chk_stock & 16384, 'hide', '') AS seatrial_hide_class,
(CASE WHEN a.boat_chk_stock & 16384 AND NOT(a.boat_chk_build & 4) THEN 'in_new' WHEN a.boat_chk_build & 4 THEN 'in_build' WHEN a.boat_chk_used & 16384 THEN 'in_brokerage' ELSE 'in_brokerage' END) AS yacht_type,
destinations.destinations AS boat_chr_regions_ids,
destinations.destinations_low AS boat_chr_regions_low_ids,
destinations.destinations_high AS boat_chr_regions_high_ids,
CONCAT('abertonyachts.com', '/', COALESCE(a.boat_img_image4, a.boat_img_image, a.boat_img_image5)) AS og_meta_image,
COALESCE(a.boat_hgt_image4, a.boat_hgt_image, a.boat_hgt_image5) AS og_meta_imageheight,
COALESCE(a.boat_wth_image4, a.boat_wth_image, a.boat_wth_image5) AS og_meta_imagewidth,
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( (CASE WHEN IFNULL(COALESCE(b.boat_chr_title,a.boat_chr_title), '') <> '' THEN COALESCE(b.boat_chr_title,a.boat_chr_title) WHEN ( SELECT COUNT(b.boat_uid_id) FROM account_boat b WHERE b.boat_cnt_account=975 AND b.boat_hld_holder IN(5531) AND b.boat_mbr_member = 0 AND (b.boat_chk_stock & 32768 OR b.boat_chk_used & 32768) AND IFNULL(b.boat_enm_flag,'NO') <> 'YES' AND IFNULL(b.boat_enm_sale,'NO') <> 'YES' AND b.boat_chr_name = IF(a.boat_hld_holder = 5531, a.boat_chr_name, COALESCE(NULLIF(a.boat_chr_name2, ''), NULLIF(a.boat_chr_name, ''), a.boat_set_builder)) ) > 1 THEN CONCAT(IF('en' = 'en', 'Yacht charter ', 'Чартер яхты '), CONVERT(@boatName USING cp1251), ' (', a.boat_uid_id, ') | Aberton Yachts') ELSE CONCAT(IF('en' = 'en', 'Yacht charter ', 'Чартер яхты '), CONVERT(@boatName USING cp1251), ' (', @year_refit, IF('en' = 'en',' year, ', ' год, '), COALESCE(b.boat_set_country,a.boat_set_country), ') | Aberton Yachts') END), '{project}', 'Aberton Yachts'), '{name}', IFNULL(CONVERT(@boatName USING cp1251), '')), '{country}', IFNULL(COALESCE(b.boat_set_country,a.boat_set_country), '')), '{year}', CONVERT(IFNULL(@year, 0) USING cp1251)), '{length}', CONVERT(@max_length USING cp1251) ) AS boat_chr_title,
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( (CASE WHEN IFNULL(COALESCE(b.boat_txt_descr,a.boat_txt_descr), '') <> '' THEN REPLACE(COALESCE(b.boat_txt_descr,a.boat_txt_descr), '{project}', 'Aberton Yachts') ELSE CONCAT( IF('en' = 'en', 'Yacht ', 'Яхта '), CONVERT(@boatName USING cp1251), ' (', @year_refit, IF('en' = 'en', ' year)', ' год)'), IF('en' = 'en', ' - price: from ', ' - цена: от '), CONVERT(@price USING cp1251), ' ', (CASE WHEN @valuta = 'EUR' THEN '€' WHEN @valuta = 'USD' THEN '$' WHEN @valuta = 'RUR' THEN '₽' ELSE '€' END), IF('en' = 'en', ' in a week', ' за неделю'), IF('en' = 'en', ', length: ', ', длина: '), GREATEST(IFNULL(a.boat_int_length, 0), IFNULL(a.boat_int_length2, 0), IFNULL(a.boat_int_length3, 0)), IF('en' = 'en', ' m', ' м'), IF('en' = 'en', ', width: ', ', ширина: '), GREATEST(IFNULL(a.boat_int_breadth, 0), IFNULL(a.boat_int_breadth2, 0)), IF('en' = 'en', ' m, ', ' м, '), COALESCE(b.boat_set_country,a.boat_set_country), IF('en' = 'en', '. Aberton Yachts - motor yacht rentals.', '. Aberton Yachts - аренда моторных яхт в России и за рубежом.') ) END), '{project}', 'Aberton Yachts'), '{name}', IFNULL(CONVERT(@boatName USING cp1251), '')), '{country}', IFNULL(COALESCE(b.boat_set_country,a.boat_set_country), '')), '{year}', CONVERT(IFNULL(@year, 0) USING cp1251)), '{length}', CONVERT(@max_length USING cp1251) ) AS boat_txt_descr,
COALESCE(b.boat_txt_keywords,a.boat_txt_keywords) AS boat_txt_keywords,
a.boat_smp_create AS boat_smp_create,
a.boat_smp_update AS boat_smp_update,
a.boat_ind_index AS boat_ind_index,
(CASE WHEN ( (a.boat_chk_attribute & 32768) OR ( CASE WHEN a.boat_hld_holder = 5531 THEN NOT((a.boat_chk_used & 32768) OR (a.boat_chk_stock & 32768)) ELSE NULL END ) OR IFNULL(a.boat_enm_redirect,'NO') = 'YES' ) THEN 410 ELSE NULL END) AS boat_sys_httpcode
FROM account_boat a
# Линковками между производителями и лодками
LEFT JOIN account_list AS brand ON brand.list_cnt_account = 975
AND brand.list_hld_holder = 8875
AND brand.list_mbr_member = 0
AND brand.list_uid_id = a.boat_lnk_shipyard
# Дополнительные значения, выражения, например для фильтра, чтобы не дублировать их несколько раз
LEFT JOIN (
SELECT
boat_uid_id,
# Максимальная длина лодки
GREATEST(IFNULL(boat_int_length, 0), IFNULL(boat_int_length2, 0), IFNULL(boat_int_length3, 0)) AS boat_int_valmaxlength,
# Количество кабин (извлекаем), может быть одно значение '5' либо два '5/6'
REGEXP_REPLACE(
REGEXP_REPLACE(
CONCAT(
REGEXP_REPLACE(
REPLACE(
REPLACE(boat_set_cabines, ' ', ''), # Убираем пробелы: "3 / 4" → "3/4"
'(', '/'), # Заменяем ( на /: "3(4)" → "3/4"
'/(NULL+).*', '/$1'), # После /X убираем всё: "3/4)+1" → "3/4"
'/'), # Добавляем / в конец: "5+5" → "5+5/"
'\\+[^/]*/', '/'), # От + до / удаляем: "5+5/" → "5/"
'/$', '') AS boat_set_valcabines, # Убираем / в конце: "5/" → "5"
# Определяем какое поле цены использовать для листинга (вся логика тут)
(CASE
# Если цена низкого и высокого сезона не нудевая, то выводим минимальную из них
WHEN NULLIF(IF(boat_hld_holder = 5531, boat_cur_cost5, COALESCE(NULLIF(boat_cur_cost5, 0), boat_cur_cost1)), 0) IS NOT NULL
AND NULLIF(IF(boat_hld_holder = 5531, boat_cur_cost9, COALESCE(NULLIF(boat_cur_cost9, 0), boat_cur_cost2)), 0) IS NOT NULL
THEN IF(IF(boat_hld_holder = 5531, boat_cur_cost5, COALESCE(NULLIF(boat_cur_cost5, 0), boat_cur_cost1)) <= IF(boat_hld_holder = 5531, boat_cur_cost9, COALESCE(NULLIF(boat_cur_cost9, 0), boat_cur_cost2)), 'low_season', 'high_season')
# Если цена низкого сезона не нулевая, то выводим её
WHEN NULLIF(IF(boat_hld_holder = 5531, boat_cur_cost5, COALESCE(NULLIF(boat_cur_cost5, 0), boat_cur_cost1)), 0) IS NOT NULL THEN 'low_season'
# Если цена высокого сезона не нулевая, то выводим её
WHEN NULLIF(IF(boat_hld_holder = 5531, boat_cur_cost9, COALESCE(NULLIF(boat_cur_cost9, 0), boat_cur_cost2)), 0) IS NOT NULL THEN 'high_season'
ELSE 'high_season'
END) AS price_field
FROM account_boat
WHERE boat_cnt_account = 975
AND boat_hld_holder IN (5531, 19422)
AND boat_mbr_member = 0
AND (
CASE
# ПРОДАЖА ЯХТ (новые+б/у)
WHEN boat_hld_holder = 5531 THEN (
(boat_chk_used & 32768 OR boat_chk_stock & 32768)
)
ELSE TRUE
END
)
) AS help_value ON help_value.boat_uid_id = a.boat_uid_id
# Линкуем список ID категорий катеров через запятую, 1008381, 104895, 104896, 104897, 105015, 104898 в BODY 2025
LEFT JOIN (
SELECT
join_this,
GROUP_CONCAT(join_that ORDER BY join_that SEPARATOR ', ') AS categories_ids
FROM reestr_join
WHERE join_account = 975
AND join_holder = 8809 # Категории лодок
AND join_this_holder = 5531
AND join_that_table = 'account_list'
AND join_this_table = 'account_boat'
AND join_that IN (1008381, 104895, 104896, 104897, 105015, 104898)
GROUP BY join_this
) tenders_categories ON tenders_categories.join_this = a.boat_uid_id
# Линкуем ID чартерных направлений, привязанных через галочки низкий и высокий сезон
LEFT JOIN (
SELECT
join_this,
GROUP_CONCAT(DISTINCT join_that) AS destinations,
GROUP_CONCAT(DISTINCT IF(join_option = 0, join_that, NULL)) AS destinations_low,
GROUP_CONCAT(DISTINCT IF(join_option = 1, join_that, NULL)) AS destinations_high
FROM reestr_join
WHERE join_account = 975
AND join_holder = 18525 # Чартерные направления - 2023
GROUP BY join_this
) AS destinations ON destinations.join_this = a.boat_uid_id
# Список материалов
CROSS JOIN (
SELECT GROUP_CONCAT(a.set_chr_name SEPARATOR ',') AS materials_list
FROM account_set a
WHERE a.set_cnt_account = 971
AND a.set_hld_holder = 17037
AND a.set_mbr_member = 0
) AS materials
LEFT JOIN account_boat b ON b.boat_ref_link=a.boat_uid_id AND b.boat_lng_language = 'en'
WHERE a.boat_cnt_account = 975
AND a.boat_hld_holder IN (5531, 19422)
AND a.boat_mbr_member = 0
AND (
CASE
# ПРОДАЖА ЯХТ (новые+б/у)
WHEN a.boat_hld_holder = 5531 THEN (
# Если стоит галочка выключить для стран не из СНГ, то проверяем страну (берётся из body), иначе TRUE
IF(IFNULL(a.boat_enm_hide,'NO') = 'YES', 1, TRUE)
# Показывать только PDF
AND IFNULL(a.boat_enm_flag, 'NO') <> 'YES'
# Не продана
AND IFNULL(a.boat_enm_sale, 'NO') = 'NO'
# Не снято с продажи
AND IFNULL(a.boat_enm_reseved, 'NO') = 'NO'
# Не снято с производства
AND IFNULL(a.boat_enm_clear, 'NO') = 'NO'
)
ELSE TRUE
END
)
AND a.boat_lng_language IS NULL /* объединение языков, всегда выбираем сначала основной */
AND a.boat_chr_link LIKE ?
ORDER BY boat_sort_irrelevant , boat_sort_search , boat_int_maxlength DESC
LIMIT 1
/* module_id:494172
URN */]