set rs=conn.execute("select *,(select count(*) from tree where pid = T.id) as children,(select pid from tree where id="&id&") as parent from tree T where pid="&id)
这个语句我看不懂,请大虾指点。也可以给我推荐一个学习sql的网站。
...全文
1198打赏收藏
分析一个复杂的sql语句:select
set rs=conn.execute("select *,(select count(*) from tree where pid = T.id) as children,(select pid from tree where id="&id&") as parent from tree T where pid="&id) 这个语句我看不懂,请大虾指点。也可以给我推荐一个学习sql的网站。
关键是你没懂select后面写的东东
其实可以参考http://access911.net
select count(*) from tree where pid = T.id我想这句你应该没什么问题,我记得上高一的时候我的数学老师说过一句话,代数就是要代换的,其实这里你也可以这么想的
as children把刚才的count带换了得到一个数量
这样一简化其实就是select *,children,parent from tree T where pid=id当然children和parent不是真实存在的而是通过语言给虚构出来的