[英]Select Statement depending on condition
如何根據主鍵選擇特定的記錄集。 假設我的主鍵是不連續的整數。 如果我指定1023(存在於表中),則應獲取下一個指定的數字(假設為50)記錄。
可以做到嗎?
有任何想法嗎?
select top 50 *
from MyTable
where MyKey > 1023
order by MyKey
Select * from [Table Name]
where primaryKey >= 1023
and primaryKey < (1023 + 50)
這取決於您要如何計算結果集。 對於要查找結果+ 50的簡單示例,可以執行以下操作:
select primaryKey+50
from [TableName]
where primaryKey=1023
如果我誤解了您的問題,請告訴我
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.