Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sqlite sqllite中的递归查询CTE_Sqlite_Recursive Query - Fatal编程技术网

Sqlite sqllite中的递归查询CTE

Sqlite sqllite中的递归查询CTE,sqlite,recursive-query,Sqlite,Recursive Query,我有下面的表结构。(我是SQL Lite新手) 我想获得Code=4的初始父级: i、 e.值2空B 我不知道如何在sqllite中编写递归查询。 提前感谢..是版本问题。。 此查询不起作用&出现语法错误。 我从3.7.17升级到了3.8.7.4版本,它运行正常 WITH RECURSIVE works(Code,Parent) AS ( Select Code,ParentCode from Relations a where a.Code=4 UNION SELEC

我有下面的表结构。(我是SQL Lite新手)

我想获得Code=4的初始父级: i、 e.值2空B

我不知道如何在sqllite中编写递归查询。 提前感谢..

是版本问题。。 此查询不起作用&出现语法错误。 我从3.7.17升级到了3.8.7.4版本,它运行正常

WITH RECURSIVE
  works(Code,Parent) AS (
   Select Code,ParentCode from Relations a where a.Code=4
    UNION
    SELECT Relations.Code, Relations.ParentCode FROM Relations , works
     WHERE Relations.Code=works.Parent
  )
SELECT * FROM works where Parent is null
你不明白这句话的哪一部分?
WITH RECURSIVE
  works(Code,Parent) AS (
   Select Code,ParentCode from Relations a where a.Code=4
    UNION
    SELECT Relations.Code, Relations.ParentCode FROM Relations , works
     WHERE Relations.Code=works.Parent
  )
SELECT * FROM works where Parent is null