MySQL: Selecting multiple fields into multiple variables in a stored procedure

后端 未结 3 1351
礼貌的吻别
礼貌的吻别 2020-12-12 18:09

Can I SELECT multiple columns into multiple variables within the same select query in MySQL?

For example:

DECLARE iId INT(20);
DECLARE dCreate DATET         


        
3条回答
  •  醉酒成梦
    2020-12-12 18:14

    Your syntax isn't quite right: you need to list the fields in order before the INTO, and the corresponding target variables after:

    SELECT Id, dateCreated
    INTO iId, dCreate
    FROM products
    WHERE pName = iName
    

提交回复
热议问题