DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `findHosts`(IN cluster_id VARCHAr(22), IN resource_id VARCHAr(22), IN linuxuser_id VARCHAr(22), IN service_type VARCHAr(10))
SQL SECURITY INVOKER
BEGIN
SET @cluster_id = cluster_id;
SET @resource_id = resource_id;
SET @linuxuser_id = linuxuser_id;
SET @service_type = service_type;
SET @all_ids = CONCAt('(SELECt hc.host_id id FROM host_component hc INNER JOIN service_', @service_type, ' s ON
hc.', @service_type, '_id = s.id) ');
SET @head = 'SELECt DISTINCT ms.id, ms.host_name, ms.ip_address, ms.region,
ms.machine_room, ms.rack, ms.cpu, ms.memory, ms.disk_usage,
ms.status, ms.mem_used, ms.disk_used, ms.cpu_used
FROM manager_host ms INNER JOIN host_component hc
ON ms.id = hc.host_id AND hc.cluster_id = ? ';
SET @service_condition = CONCAt('AND hc.host_id NOT IN ', @all_ids);
SET @tail = 'ORDER BY ms.host_name';
SET @resource_condition = 'AND hc.resource_id = ? ';
SET @linuxuser_condition = 'AND hc.linux_user_id = ? ';
SET @host_sql = CONCAt(@head, @service_condition);
IF (@resource_id IS NOT NULL, @resource_id <> '')
THEN SET @host_sql = CONCAt(@host_sql, @resource_condition);
END IF;
IF (@linuxuser_id IS NOT NULL, @linuxuser_id <> '')
THEN SET @host_sql = CONCAt(@host_sql, @linuxuser_condition);
END IF;
SET @host_sql = CONCAt(@host_sql, @tail);
PREPARE result FROM @host_sql;
EXECUTE result USING @cluster_id, @resource_id, @linuxuser_id;
DEALLOCATE PREPARE result;
END$$
DELIMITER ;
call CALL findHosts('DH90GH9_FHF4GHD3DNP4CG', '', '', 'storm');
Error Code: 1241
Operand should contain 1 column(s)
mysql error1241:Operand should contain 1 column(s)
答案:2 悬赏:50 手机版
解决时间 2021-03-03 05:24
- 提问者网友:不要迷恋哥
- 2021-03-02 23:34
最佳答案
- 五星知识达人网友:雾月
- 2021-03-03 00:37
mysql error1241:Operand shou--根据报错来看 ,你下面的一个查询返回了两个值 cou_name as 最优秀课程,sco_score as 成绩
--Operand should contain 1 column(s)
(select cou_name as 最优秀课程,sco_score as 成绩 from cou,sco where cou.cou_id=sco.cou_id group by stu_id having sco_score=max(sco_score)),
(select cou_name as 最差课程,sco_score as 成绩 from cou,sco where cou.cou_id=sco.cou_id group by stu_id having sco_score=min(sco_score)),ld contain 1 column(s)
--Operand should contain 1 column(s)
(select cou_name as 最优秀课程,sco_score as 成绩 from cou,sco where cou.cou_id=sco.cou_id group by stu_id having sco_score=max(sco_score)),
(select cou_name as 最差课程,sco_score as 成绩 from cou,sco where cou.cou_id=sco.cou_id group by stu_id having sco_score=min(sco_score)),ld contain 1 column(s)
全部回答
- 1楼网友:北方的南先生
- 2021-03-03 01:59
--根据报错来看 ,你下面的一个查询返回了两个值 cou_name as 最优秀课程,sco_score as 成绩
--operand should contain 1 column(s)
(select cou_name as 最优秀课程,sco_score as 成绩 from cou,sco where cou.cou_id=sco.cou_id group by stu_id having sco_score=max(sco_score)),
(select cou_name as 最差课程,sco_score as 成绩 from cou,sco where cou.cou_id=sco.cou_id group by stu_id having sco_score=min(sco_score)),
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯