我之前没有使用sqlite,也无法弄清楚语法,如果有帮助,我在sql Server中使用它.
我需要将结果放入临时表中,以便重用它们.
// sql Server
WITH FT_CTE AS ( SELECT pID,cID FROM brftNode_Children WHERE pID = 1 UNION ALL SELECT e.pID,e.cID FROM brftNode_Children e INNER JOIN FT_CTE ftCTE on (ftCTE.cID = e.pID) ) SELECT * INTO #ParentChild FROM FT_CTE;
// sqlite试试
WITH FT_CTE AS ( SELECT pID,e.cID FROM brftNode_Children e INNER JOIN FT_CTE ftCTE on (ftCTE.cID = e.pID) ) CREATE TEMPORARY TABLE ParentChild as SELECT * FROM FT_CTE;
CREATE TABLE statement不允许CTE,但SELECT会:
CREATE TEMPORARY TABLE ParentChild AS WITH FT_CTE AS ( SELECT pID,cID FROM brftNode_Children WHERE pID = 1 UNION ALL SELECT e.pID,e.cID FROM brftNode_Children e INNER JOIN FT_CTE ftCTE ON (ftCTE.cID = e.pID) ) SELECT * FROM FT_CTE;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。