workbench - how to use stored functions mysql (Error Code: 1054 Unknown column 'Right Index' in 'field list') -


how use stored functions mysql

drop function if exists finger_name; delimiter \\ create definer=`root`@`localhost` function `finger_name`(finger_id int)  returns `varchar`(45) charset `utf8` begin declare name `varchar`(45); case finger_id     when 1 set name= `right thumb`;     when 2 set name= `right index`;     when 3 set name= `right middle`; else set name= `not registered`; end case; return name; end\\  delimiter ;  select finger_name(2); 

error code: 1054 unknown column 'right index' in 'field list

if setting string literal in variable, should use single quote , not backtick -- used identifiers such table name, column names, etc...

case finger_id when 1     set name= 'right thumb'; when 2     set name='right index'; ..... 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -