如何停止对特定记录的SQL搜索?
我要搜查一下如何停止对特定记录的SQL搜索?,sql,Sql,我要搜查一下 select product_code,data_code from prod_text where (product_code like 'all%' and data_code like 'ABCDE') order by Data_Code 这会从数据库中按顺序输出我的ABCDE代码(不是数字/文本顺序),但我也想在达到特定的“数据\代码”后停止搜索,然后继续下一个产品 1 4 2 3 6 5 gives output 1 4 2 3 3 2 6 5 4 1 give
select product_code,data_code
from prod_text
where (product_code like 'all%' and data_code like 'ABCDE')
order by Data_Code
这会从数据库中按顺序输出我的ABCDE代码(不是数字/文本顺序),但我也想在达到特定的“数据\代码”后停止搜索,然后继续下一个产品
1 4 2 3 6 5 gives output 1 4 2 3
3 2 6 5 4 1 gives output 3 2
如果我选择6作为我的“停止”数据\u代码
任何解决方案都非常受欢迎您是按数据代码订购的,这样的解决方案是否适合您
select product_code,data_code
from prod_text
where (product_code like 'all%' and data_code like 'ABCDE')
and data_code < @stop
order by Data_Code
选择产品代码、数据代码
从产品文本
其中(产品代码如“all%”和数据代码如“ABCDE”)
和数据_代码<@stop
按数据顺序\u代码
如果您只想在实际找到“停止”数据代码时停止,您可以使用子查询解决它。您使用的是什么数据库?请为您的DBMS(postgresql、oracle、sql server等)添加标记。什么定义了您的顺序?i、 e.为什么是
1,4,2,3,6,5',而不是1,2,3,4,5,6,或者6,5,4,3,2,1`等等。