[英]Select Statement depending on condition
How to select a particular set of records depending on Primary Key. 如何根据主键选择特定的记录集。 Suppose my Primary Key is integer which are not sequential.
假设我的主键是不连续的整数。 If I specify 1023(which exists in table) then I should get the next specified number(suppose 50) records.
如果我指定1023(存在于表中),则应获取下一个指定的数字(假设为50)记录。
Can this be possible to do it? 可以做到吗?
Any Ideas? 有任何想法吗?
select top 50 *
from MyTable
where MyKey > 1023
order by MyKey
Select * from [Table Name]
where primaryKey >= 1023
and primaryKey < (1023 + 50)
It depends on how you want to calculate the result set. 这取决于您要如何计算结果集。 For the simple example where you want to find the result + 50, you can do something like this:
对于要查找结果+ 50的简单示例,可以执行以下操作:
select primaryKey+50
from [TableName]
where primaryKey=1023
If I've misunderstood your question, please let me know 如果我误解了您的问题,请告诉我
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.