[英]Pervasive SQL Update with top
我正在尋找這樣做:
update aTable
set aField = 'value'
where aTable.Id in (select top 400 Id from aTable order by dateField) .
-- This will run, but it only updates the first id it gets to in the IN clause
或這個:
update top 400 aTable set aField = 'value' order by dateField
-- This will not run
但是,它必須在Pervasive V10中工作。
類似的解決方法也足夠了!
背景,我試圖用日期字段排序的值更新(項目的編號(可變))字段。
這是Pervasive的Update幫助(我在那里看不到TOP保留字):
UPDATE < table-name | view-name > [ alias-name ]
SET column-name = < NULL | DEFAULT
| expression | subquery-
expression > [ , column-name = ... ]
[ FROM table-reference [, table-reference ] ...
[ WHERE search-condition ]
table-name ::= user-defined-name
view-name ::= user-defined-name
alias-name ::= user-defined-name (Alias-name is not allowed if a
FROM clause is used. See FROM Clause .)
table-reference ::= { OJ outer-join-definition }
| [db-name.]table-name [ [ AS ] alias-name ]
| [db-name.]view-name [ [ AS ] alias-name ]
| join-definition | ( join-definition )
| ( table-subquery )[ AS ] alias-name [ (column-name [ , column-name
]... ) ]
我進行了一些測試,使此工作正常的最佳方法是創建一個視圖:
創建視圖View1作為按dateField從aTable順序中選擇ID的視圖;
然后使用更新中的視圖:
更新aTable設置aField ='value'其中aTable.Id在(從View1a中選擇頂部400 a.Id);
我已經對PSQL v11進行了測試,但它也應與PSQL v10一起使用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.