Blogger Information
Blog 143
fans 1
comment 0
visits 440511
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
mysql递归查询
弘德誉曦的博客
Original
2106 people have browsed it

 SELECT
c.id 
FROM
(
SELECT
a.id,
IF( FIND_IN_SET( a.pid, @pids ) > 0,
IF( length( @pids ) - length( REPLACE ( @pids, a.pid, '' ) ) > 1,
IF( length( @pids ) - length( REPLACE ( @pids, a.id, '' ) ) > 1,
@pids, @pids := concat( @pids, ',', a.id ) ),@pids := concat( @pids, ',', a.id ) ), 0  ) AS 'plist',
IF( FIND_IN_SET( a.pid, @pids ) > 0, @pids, 0 ) AS ischild 
FROM
( SELECT r.id, r.pid FROM youbang_sys_acount r ) a,
( SELECT @pids := 1 ) b 
) c 
WHERE
c.ischild != 0


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post