小编典典

关键字“ with”附近的语法不正确(SQL)

sql

我有一个奇怪的问题。

当我运行此SQL时:

with ID_Table as ( 
    select row_number() over (order By SS_ID) As row_id, 
             ss_id 
      from slide_show ) 
     select t0.* 
       from ID_Table as t1 
inner Join slide_show as t0 on t1.ss_id = t0.ss_id 
    where t1.row_id between 0 and 1 
 order by t1.row_id asc;

在SQL Express中,它将运行并按需返回第一行(类似于MySQL中的Limit
0,1)。但是,当我通过TADOQuery对象在delphi中运行此程序时,我收到了标题中的错误。我猜想ADO对象在此过程中正在做一些事情,但我不知道要做什么。

注意:这是我要传递给ADO对象的确切SQL。

有人有什么想法吗?


阅读 243

收藏
2021-04-22

共1个答案

小编典典

尝试:

SELECT t0.*
FROM (SELECT row_number() over(ORDER BY SS_ID) AS row_id, ss_id FROM slide_show) AS t1
INNER JOIN slide_show AS t0
ON t1.ss_id = t0.ss_id
WHERE t1.row_id BETWEEN 0 AND 1
ORDER BY t1.row_id ASC;
2021-04-22