mercredi 21 décembre 2016

More than one row as result

I have the following procedure that I made to basically transfer the values from one of the two columns "not_good and good" to the column "comment" in the same table using the grade value:

DELIMITER $$
CREATE OR REPLACE PROCEDURE add_comments()
BEGIN

DECLARE var INT;
SELECT grade INTO var FROM table2;

    IF (var <= 7) THEN
        UPDATE table2 set comment = not_good;
    ELSE
        UPDATE table2 set comment = good;
    END IF;
END$$
DELIMITER ;

When I CALL add_comentarios(); I receive the following error:

#1172 - Result consisted of more than one row

Can't figure out how to make it work as I want

PS: I'm a begginer rsrs

Thanks a lot for any answer!

Aucun commentaire:

Enregistrer un commentaire