E
E
entermix2016-04-21 23:19:11
MySQL
entermix, 2016-04-21 23:19:11

Is it possible to do multiple SELECT INTO?

Допустим есть:
DECLARE _balance INT(11);
DECLARE _balance2 INT(11);

SELECT `balance` INTO _balance FROM `users` WHERE `id` = `NEW`.`user_id` LIMIT 1;

We take the value of the variable _balance from the table users, but what if we need to take several columns at once? That is balance, balance2
something like:
SELECT `balance` INTO _balance, `balance2` INTO _balance2 FROM `users` WHERE `id` = `NEW`.`user_id` LIMIT 1;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maa-Kut, 2016-04-21
@entermix

DECLARE _balance INT(11);
DECLARE _balance2 INT(11);

SELECT `balance`, `balance2` INTO _balance, _balance2 
FROM `users` WHERE `id` = `NEW`.`user_id` LIMIT 1;

Details: dev.mysql.com/doc/refman/5.7/en/select.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question