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
Sqlite 使用SQL“With”子句时出错_Sqlite - Fatal编程技术网

Sqlite 使用SQL“With”子句时出错

Sqlite 使用SQL“With”子句时出错,sqlite,Sqlite,这就是我正在使用的查询。我在这个查询中遇到了一个错误。”“WITH”子句附近的语法错误 WITH RECURSIVE under_cust (affiliation_id, from_customer_id, to_customer_id, to_name, parent_customer_type, child_customer_type, level) AS (SELECT af.affiliation_id, from_customer_id,

这就是我正在使用的查询。我在这个查询中遇到了一个错误。”“WITH”子句附近的语法错误

WITH RECURSIVE under_cust (affiliation_id, from_customer_id, to_customer_id, to_name,     parent_customer_type, child_customer_type, level) 
 AS (SELECT af.affiliation_id, 
       from_customer_id, 
       to_customer_id, 
       to_name, 
       parent_customer_type, 
       child_customer_type, 
       0 LEVEL 
     FROM   affiliation af, 
                customer c 
         WHERE  to_customer_id <> from_customer_id 
                AND af.from_customer_id = c.customer_id 
                AND af.to_customer_id = 1000022559337 
         UNION ALL 
         SELECT af.affiliation_id, 
                af.from_customer_id, 
                af.to_customer_id, 
                af.to_name, 
                af.parent_customer_type, 
                af.child_customer_type, 
                under_cust.level + 1 LEVEL 
         FROM   customer c, 
                affiliation af 
                JOIN under_cust smr 
                  ON smr.from_customer_id = af.to_customer_id 
         WHERE  af.from_customer_id = c.customer_id 
) SELECT affiliation_id, 
   to_customer_id   parent, 
   from_customer_id child, 
   to_name, 
   parent_customer_type, 
   child_customer_type, 
   level 
FROM   under_cust 

公共表表达式和WITH语法最近才在中引入

如果在旧版本上运行查询,则会出现语法错误


升级您的sqlite或使代码在不使用WITH语法的情况下工作。

您有哪个版本的sqlite?在3.8.3中添加了公共表表达式-文件扩展名为“.sqlite3”。如何查找版本?如何运行查询?如果是sqlite3 shell,那么您可以使用例如sqlite3-versionOr执行SELECT sqlite_version;找到版本;。好的,谢谢。它是旧版本3.7.17。需要在不使用“with”子句的情况下考虑其他选项。。