drop view if exists view_cottage_from_second; create view view_cottage_from_second as select id as obj_id, 0 as obj_rev, 0 as obj_base, seller_id as obj_owner, if (active='Y',91,92) as obj_status, date as obj_date, checked_date as obj_checked_date, '' as obj_xls_md5, 0 as obj_source_id, 0 as _id, village_id as obj_village, type as obj_type, city as obj_city, district as obj_district, direction as obj_direction, distance as obj_section_a, 0 as obj_section_b, street as obj_address, add_address as obj_add_address, floor_house as obj_floor_house, square_all as obj_square_house, if(type in (42, 428, 29), square_use, 0) as obj_square_area, material as obj_material, price as obj_price_min, price as obj_price_max, price_type as obj_price_type, '' as obj_price_detail, 0 as obj_water, 0 as obj_sewage, 0 as obj_heat, 409 as obj_compl, 100 as obj_compl_stage, detail as obj_detail, street_id as obj_street_id, phone_num as obj_phone_num, phone_cont as obj_phone_cont, special_offer as obj_special_offer, 0 as obj_square_unit, square_all as obj_square_all, square_use as obj_square_use, square_kit as obj_square_kit from second where active = 'Y' and (tmp!='Y' or tmp is null);