SELECT INTO Variable in MySQL DECLARE causes syntax error?

前端 未结 11 2142
無奈伤痛
無奈伤痛 2020-11-30 21:48

I´d like to SELECT a single value into a variable. I´d tried to following:

DECLARE myvar INT(4);

-- immediately returns some syntax error.<

11条回答
  •  误落风尘
    2020-11-30 22:29

    It is worth noting that despite the fact that you can SELECT INTO global variables like:

    SELECT ... INTO @XYZ ...

    You can NOT use FETCH INTO global variables like:

    FETCH ... INTO @XYZ

    Looks like it's not a bug. I hope it will be helpful to someone...

提交回复
热议问题