SELECT INTO Variable in MySQL DECLARE causes syntax error?

前端 未结 11 2143
無奈伤痛
無奈伤痛 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:30

    Per the MySQL docs DECLARE works only at the start of a BEGIN...END block as in a stored program.

提交回复
热议问题