Error Code: 1241 Operand should contain 1 column(s) MySQL

1.2k views Asked by At

I am getting error message 'Operand should contain 1 column(s)' when executes a stored procedure in MySQL.

Following is the stored procedure:

DELIMITER $$

USE `test`$$

DROP PROCEDURE IF EXISTS `test_proc`$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `test_proc`(IN inputMsisdn BIGINT)
BEGIN

    IF(CHAR_LENGTH(inputMsisdn)=12, SUBSTR(3,inputMsisdn), inputMsisdn)
    THEN
        SELECT rmnum FROM testbase WHERE msisdn=inputMsisdn;
    END IF;
    END$$

DELIMITER ;

Can you please tell me whats the problem within this procedure?

2

There are 2 answers

0
Bill Karwin On
IF(CHAR_LENGTH(inputMsisdn)=12, SUBSTR(3,inputMsisdn), inputMsisdn)

The condition in an IF must be a single scalar, but you have commas so it's trying to treat it as a list of values. Perhaps you meant to use AND where you have commas?

0
Christian On

I think the error is on this line

IF(CHAR_LENGTH(inputMsisdn)=12, SUBSTR(3,inputMsisdn), inputMsisdn) but i couldnt tell you why :)