Why mysql is giving error “Not allowed to return a result set from a function”?

前端 未结 2 1493
情书的邮戳
情书的邮戳 2020-12-01 16:54

I am trying to create a MySQL function using phpMyAdmin and getting this error.

#1415 - Not allowed to return a result set from a function

2条回答
  •  旧时难觅i
    2020-12-01 17:24

    Because

    SELECT left_id AS c1 FROM mlm_user_mst WHERE parent_id=a AND left_id>0; 
    

    doesn't set the variable c1, it returns a set with a column named c1

    You want

    SELECT left_id INTO c1 FROM mlm_user_mst WHERE parent_id=a AND left_id>0; 
    

    Similarly for c2.

提交回复
热议问题