简体   繁体   English

错误代码:1241操作数应包含1列MySQL

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

I am getting error message 'Operand should contain 1 column(s)' when executes a stored procedure in MySQL. 在MySQL中执行存储过程时,出现错误消息“操作数应包含1列”。

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? 您能告诉我这个程序有什么问题吗?

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. IF中的条件必须是单个标量,但是您有逗号,因此它试图将其视为值列表。 Perhaps you meant to use AND where you have commas? 也许您打算在有逗号的地方使用AND

I think the error is on this line 我认为错误在这条线上

IF(CHAR_LENGTH(inputMsisdn)=12, SUBSTR(3,inputMsisdn), inputMsisdn) but i couldnt tell you why :) IF(CHAR_LENGTH(inputMsisdn)=12, SUBSTR(3,inputMsisdn), inputMsisdn)但我无法告诉您原因:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM