私は小さな関数を書きました:
CREATE TABLE states
(`id` int, `name` varchar(2))
;
INSERT INTO states
(`id`, `name`)
VALUES
(1, 'md'),
(2, 'tx'),
(3, 'ma')
;
delimiter //
create function states_repeated (s varchar(2))
returns int
begin
insert into sid select count(*) from states where states.name=s ;
return sid ;
end//
delimiter ;
select states_repated('ma') ;
しかし、これは戻ります
ERROR 1146 (42S02): Table 'test.sid' doesn't exist
この値を返すにはどうすればよいですか?