Mysql : Not allowed to return a result set from a function

前端 未结 2 1834
陌清茗
陌清茗 2021-01-27 17:46

I have write one function but getting this error Not allowed to return a result set from a function

DEL         


        
2条回答
  •  时光说笑
    2021-01-27 18:18

    You want to assign the result of a query to a variable, but in fact you're just selecting. That's why MySQL's complaining.

    You have to change this

                SELECT  p_KeyValue = ListName + '.' + Value
                FROM ListsTable
                WHERE EntryID = p_ParentID  LIMIT 1 ;
    

    to

                SELECT CONCAT(ListName, '.', `Value`)
                INTO p_KeyValue
                FROM ListsTable
                WHERE EntryID = p_ParentID  LIMIT 1 ;
    

    And you should add an ORDER BY. A LIMIT without ORDER BY doesn't make sense, since there's no guaranteed order in a relational database.

提交回复
热议问题