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
During the work development process, a requiremen...
In the process of writing HTML, we often define mu...
Table of contents 1. Scopes are expressed in diff...
For example: <u> This has no ending characte...
Go is an open source programming language that ma...
Download the redis image docker pull yyyyttttwwww...
The operating system for the following content is...
The three-dimensional column chart consists of th...
Method 1: Command line modification We only need ...
Since Zabbix version 3.0, it has supported encryp...
Page domain relationship: The main page a.html bel...
Table of contents 1. Initialize the array 2. Arra...
Method 1: Submit via the submit button <!DOCTY...
webpack loads css files and its configuration Aft...
There is a big difference between the writing ord...