关键字'with'(SQL)附近的语法不正确 [英] Incorrect syntax near the keyword 'with' (SQL)
本文介绍了关键字'with'(SQL)附近的语法不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一点奇怪的问题。
当我运行这个SQL时:
When I run this 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;
它运行并返回第一行(类似于Limit 0, 1在MySQL中)。但是,当我通过TADOQuery对象在delphi中运行它时,我在标题中收到错误。我猜测ADO对象正在做某些事情,但我不明白什么。
in SQL Express, it runs and returns the first row as it should (similar to the Limit 0,1 in MySQL). However, when I run this in delphi via the TADOQuery object, I receive the error in the title. I am guessing the ADO object is doing something along the way but I don't understand what.
注意:这是我传入ADO对象的确切SQL。
Note: This is the exact SQL I am passing into the ADO object.
有没有人有任何想法?
推荐答案
尝试: p
Try:
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;
这篇关于关键字'with'(SQL)附近的语法不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文