drop view if exists second_search; create view second_search as select *, 0 as square_house, 0 as square_area, 'second' as search_base from second where ((tmp != 'Y') or (tmp is null)) and (active <> 'N') and ((type in (18,44,41,115)) or ((city <> 121) and type in (29, 42, 428))) union select *, 'cottage' as search_base from view_second_from_cottage where (active <> 'N') and (city <> 121);