drop view if exists cottage_search; create view cottage_search as select *, if(obj_type=158,'dacha','house') as obj_suburban_type, 'second' as obj_search_base from view_cottage_from_second where (obj_type = 158) or (obj_city=121) union select *, 'cottage' as obj_suburban_type, 'second' as obj_search_base from view_cottage_from_second where (obj_type = 42) and (obj_city = 121) union select *, 0 as obj_square_unit, 0 as obj_square_all, 0 as obj_square_use, 0 as obj_square_kit, 'cottage' as obj_suburban_type, 'cottage' as obj_search_base from cottage where obj_city = 121 union select *, 0 as obj_square_all, 0 as obj_square_use, 0 as obj_square_kit, 'zem' as obj_suburban_type, 'zem' as obj_search_base from view_cottage_from_zem;