Selecting multiple fields into multiple variables in a MySQL stored procedure

Posted by Stuart on Stack Overflow See other posts from Stack Overflow or by Stuart
Published on 2010-03-15T21:12:40Z Indexed on 2010/03/15 22:49 UTC
Read the original article Hit count: 717

I am a little new to store procedures in MySQL and was wondering if I can SELECT multiple columns into multiple variables within the same select query.

for example (iName is the input to the function):

DECLARE iId INT(20);
DECLARE dCreate DATETIME;

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

Thanks

© Stack Overflow or respective owner

Related posts about mysql

Related posts about sql