0
整數返回0我已經在mysql中創建了這個功能,我想與像(1,0,-2,-1)
而是它給結果cocated值導致0
MySQL的追加與功能
DROP Function IF EXISTS get_preorder_status;
DELIMITER $$
CREATE Function get_preorder_status(loc_pre_order_id int) RETURNS INT(10)
BEGIN
DECLARE all_status CHAR(10) DEFAULT '';
DECLARE temp_status INT(2);
DECLARE n INT DEFAULT 0;
DECLARE i INT DEFAULT 0;
SELECT count(*) into n
FROM pre_order_detail
WHERE pre_order_id = loc_pre_order_id;
WHILE i<n DO
SELECT customer_response_status into temp_status
FROM pre_order_detail
WHERE pre_order_id = loc_pre_order_id LIMIT i,1;
SET all_status = CONCAT(all_status,', ',CAST(temp_status AS CHAR));
SET i = i + 1;
END WHILE;`
RETURN all_status;
END$$
DELIMITER ;
all_status是char類型的變量,但temp_status是INT字符我想CONCAT最終結果與逗號在一個字符串類型值的整數值saparated
請幫
哦,謝謝。我是傻瓜我沒有注意到返回類型 – JItender
是的,我需要循環,因爲這是關係數據庫的一對多映射,與表'pre_order'和'pre_order_detail',我需要cancat所有子表數據的狀態 – JItender