As shown in the figure: Table Data For such a tree, how to get all the nodes under "Gao Yinrui" (one SQL statement is definitely not enough) Write via stored procedure DELIMITER // CREATE FUNCTION `getChildLst`(rootId INT) RETURNS varchar(1000) READS SQL DATA BEGIN DECLARE sTemp VARCHAR(1000); DECLARE sTempChd VARCHAR(1000); SET sTemp = '$'; SET sTempChd =cast(rootId as CHAR); WHILE sTempChd is not null DO SET sTemp = concat(sTemp,',',sTempChd); SELECT group_concat(id) INTO sTempChd FROM document_file_name where FIND_IN_SET(pId,sTempChd)>0; END WHILE; RETURN sTemp; END // Create the above stored procedure select * from document_file_name where find_in_set(id, getChildLst(1)); Summarize This is the end of this article about how to use stored procedures in MySQL to get tree nodes. For more information about how to get tree nodes in MySQL stored procedures, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Native js custom right-click menu
>>: js to achieve cool fireworks effect
Preface: Partitioning is a table design pattern. ...
Problem description: After the front-end deletes ...
Table of contents 1. Introduction to import_table...
I recently reviewed some CSS-related knowledge po...
1. Absolute path First of all, on the local compu...
Common methods for limiting input 1. To cancel the...
In this experiment, we configure MySQL standard a...
0x00 Introduction A few months ago, I found a vul...
1. Rendering JD Effect Simulation Effect 2. Princ...
Table of contents 1. Closure 2. Closure usage sce...
Knowing which for loop or iterator is right for o...
Container is another core concept of Docker. Simp...
The communication modes of vue3 components are as...
Let me first introduce to you that the node proce...
This article example shares the specific code of ...