Home > Database > Mysql Tutorial > with as 递归

with as 递归

WBOY
Release: 2016-06-07 14:57:37
Original
1895 people have browsed it

withas递归 id|parentid|Code 1|null|S1409110001 2|1|S1409170004 3|2|S1409170006 无 with accountrp AS( SELECT TOP 1 uid,uaccountrpid,ccode from t_accountrp where ccode='S1409170006' UNION ALLSELECT t_accountrp.uid,t_accountrp.uaccountrpid,t_a

with as 递归
id | parentid | Code
1  | null         | S1409110001
2  |1              | S1409170004
3  |2              | S1409170006
with accountrp AS(
  SELECT TOP 1 uid,uaccountrpid,ccode from t_accountrp where ccode='S1409170006' 
	UNION ALL
	SELECT  t_accountrp.uid,t_accountrp.uaccountrpid,t_accountrp.ccode 
		from accountrp inner join t_accountrp on accountrp.uaccountrpid=t_accountrp.uid
 )select  * from accountrp ORDER BY ccode;
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template