mardi 20 mars 2018

MySQL Error 1241 Operand should contain 1 column(s) on IF EXISTS

I have been getting this Error 1241 Operand should contain 1 column(s) in a Stored Procedure in MySQL.

This error has been highly cited in other posts, but none of these fitted my situation, and so I have created a question & answer to help others who may be struggling with the source of this error, and in which the other answers do not lead to the solution.

Here is a reduction of my code:

DELIMITER //
DROP PROCEDURE IF EXISTS TEST
//
CREATE PROCEDURE TEST()
BEGIN
    IF NOT (SELECT * FROM categories) THEN
        SELECT 1;
    END IF;
END;
//

CALL TEST();

This compiles OK, but generates the runtime error 1241 error.

Aucun commentaire:

Enregistrer un commentaire