I have following situation:
CREATE TABLE `city` ( `City_ID` int(11) NOT NULL, `CityName` varchar(20) NOT NULL, `Nomer` smallint(6) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;INSERT INTO `city` (`City_ID`, `CityName`, `Nomer`) VALUES(7, 'Берлин', NULL),(2, 'Васюки', NULL),(3, 'Челябинск', NULL),(4, 'Магадан', NULL),(5, 'Екатеринбург', NULL),(209, 'Чебоксары', NULL),(455, 'Санкт-Петербург', NULL),(6, 'Москва', NULL),(458, 'Sochi', NULL),(8, 'Париж', NULL),(9, 'Бонн', NULL),(10, 'London', NULL);drop function if exists WhatIsCityName;delimiter $$create function WhatIsCityName(id int)returns varchar(20)beginselect cityname into @cityname from city where city_id=id;return @cityname;END $$delimiter ;select WhatIsCityName(7);
Last select returns '??????' instead of 'Берлин', thoughselect WhatIsCityName(); returns correct value 'Moscow'