CREATE DEFINER=`root`@`%` FUNCTION `GET_CHILD_COMMENT_STR`(id VARCHAR(50)) RETURNS longtext CHARSET utf8mb4
SQL SECURITY INVOKER
BEGIN
DECLARE r LONGTEXT default '';
set r = (SELECT GROUP_CONCAT(PICK_COMMENT_ID) FROM (
SELECT T1.PICK_COMMENT_ID,
IF(FIND_IN_SET(REPLY_PICK_COMMENT_ID, @PIDS) > 0, @PIDS := CONCAT(@PIDS, ',', PICK_COMMENT_ID), 0) AS ISCHILD
FROM (
SELECT PICK_COMMENT_ID,REPLY_PICK_COMMENT_ID FROM APP_PICK_COMMENT T WHERE T.STATUS = '0' ORDER BY T.REPLY_PICK_COMMENT_ID, T.PICK_COMMENT_ID
) T1,
(SELECT @PIDS := id) T2
) T3 WHERE ISCHILD != 0);
RETURN r;
END
网友评论