gpt4 book ai didi

mysql - 'case' 语句中的子句之一的条件失败

转载 作者:行者123 更新时间:2023-11-29 13:04:53 24 4
gpt4 key购买 nike

DELIMITER $$

USE `mg_ims`$$

DROP PROCEDURE IF EXISTS `sp_get_drop_down_data`$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_get_drop_down_data`(

IN _name VARCHAR(15))

BEGIN

CASE

WHEN _name = 'CUSTOMERS' THEN

SELECT cust_id,cust_name,address FROM tb_customers;

WHEN _name = 'SUPPLIERS' THEN

SELECT supp_name FROM tb_suppliers;

WHEN _name = 'BRANDS' THEN

SELECT b.name FROM tb_brands b;

WHEN _name = 'REGIONAL_OFFICES' THEN

SELECT r.name FROM tb_area_offices r;

WHEN _name = 'SUB_OFFICES' THEN

SELECT s.name FROM tb_locations s;

ELSE

SELECT 404 `Code`,'Case not Found' Description;

END CASE;

END$$


DELIMITER ;

除了“regional_offices”之外,上述所有情况都正常工作...尽管语法和逻辑是正确的...

最佳答案

您的问题是 _namevarchar(15),但字符串 'REGIONAL_OFFICES' 长度为 16 个字符!

关于mysql - 'case' 语句中的子句之一的条件失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22854030/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com