Table './u206051_12/catalog' is marked as crashed and should be repaired
select T.*,BR.name as brand_name,BR.logo as brand_logo,CNTR.name as brand_country_name,CITY.name as brand_city_name,BR.geo as brand_geo,FLD.name as section_name,FLD.url as folder_url,FLD.pos as section_pos,B.name as brand_name,ST.name as cst_name,ST.id as cst_id,(select PH.id from catalog_photos as PH where PH.item_id=T.id order by PH.pos limit 1) as photo_id,T.is_stack,1 as avail_in_region,@count_variants := IFNULL( ( select count(CIV.id) from catalog_item_variants as CIV where CIV.item_id = T.id AND CIV.active = 1 ), 0 ),IFNULL(@count_variants, 0) as count_variants,@price := ifnull( ( select CPR.price from catalog_prices as CPR where CPR.price_type_id = 6 and CPR.product_id = T.id and IFNULL(CPR.variant_id, 0) = 0 limit 1 ), T.price ),@product_discount := ifnull( ( select CPR.discount from catalog_prices as CPR where CPR.price_type_id=6 and CPR.product_id=T.id and IFNULL(CPR.variant_id, 0) = 0 limit 1 ), IF (T.is_stack, T.discount, 0) ),@aff_package := IF( @count_variants > 0, "", ( select CPR.package from catalog_prices as CPR where CPR.price_type_id=6 and CPR.product_id=T.id and IFNULL(CPR.variant_id, 0) = 0 limit 1 ) ),IF( IFNULL(@aff_package, "") = "", T.package, @aff_package ) as package,0 as old_price,ifnull( ( select CPR.no_discount_cart from catalog_prices as CPR where CPR.price_type_id=6 and CPR.product_id=T.id and IFNULL(CPR.variant_id, 0) = 0 order by price limit 1 ), 0 ) as no_discount_cart,@discount := @product_discount,IF( @discount = 0, @price, round( cast( @price * (1 - (@discount / 100)) as decimal ) ) ) as price, @price as price_real,@discount as discount,@quantity := ifnull( ( select sum(STOCK.quantity) from catalog_stocks_products as STOCK where STOCK.stock_id = 3 and STOCK.product_id = T.id ), 0 ),@avail := IF(@quantity > 0, 1, 0),@quantity as quantity,@avail as avail,NULL as delivery_time,( CASE WHEN T.is_stack = 0 AND IFNULL(delivery_time, "") = "" THEN @avail ELSE 1 END ) as avail_order from ((catalog as T,folders as FLD) left join brands as B on B.id=T.brand left join brands as BR on BR.id = T.brand left join countries as CNTR on CNTR.id = BR.country_id left join countries_cities as CITY on CITY.id = BR.city_id left join currency as CR on CR.id=T.currency left join catalog_special_products as CST on T.id=CST.product_id and (select count(AST.affiliate_id) from affiliates_special_types as AST where AST.type_id=CST.special_type and AST.affiliate_id=2 limit 1) = 1 left join catalog_special_types as ST on CST.special_type=ST.id) where T.active=1 and FLD.id=T.folder_id and (select count(TRM.id) from catalog_property_values as TRM where TRM.item_id = T.id and TRM.term_id in (67)) = 1 and (select count(AFF.affiliate_id) from affiliates_catalog as AFF where AFF.affiliate_id=2 and AFF.product_id=T.id) > 0 and (1) group by T.id order by avail desc, T.sale_rating desc,T.price