如何按字母顺序将行排序为小结果集。 [英] How to sort rows alphabetically into small result sets.

查看:80
本文介绍了如何按字母顺序将行排序为小结果集。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 property 的表,其中包含一列(propertyNames)。表有大约75000行。



我的任务:

我想获取json文件中的所有行。每个json文件应仅包含6个记录,但按字母顺序排列。



例如:

a.json应包含以a开头的记录。 br />
aa.json应包含以aa开头的记录。

ab.json应包含以ab开头的记录。

harry.json应包含记录开头哈利。



这就是我想在我的应用程序中快速搜索所做的一切。当用户在搜索框中键入一些单词而不是自动完成时,将查找匹配的json文件并显示其中的记录。某种技术用于 IMDB 搜索。我正在尝试使用静态json文件来应用相同的内容。



IMDB搜索如何快速运行?



问题:

因为我说我在表中有一条列有75000条记录,我如何创建一小组记录(每条记录有6条记录的数据),所以我可以通过我的应用程序将它转换成json文件。 />


我试过这个喜欢

例如:

选择*来自物业,其中propertyNames如'a%'

我从75000获得了3000条记录,以。

开头,但我不希望3000条记录应包含在一个json文件。所以我再次尝试用像'a%'

所以我得到了19条记录。再次尝试用像'ab%'得到80条记录。



所以,我只为 a 做了这一切。我仍然没有得到一个渴望的结果(每个6个)。我正在使用的方法来获得非常耗时的欲望结果。



如何获得此记录?我需要申请哪些逻辑?您可以分享我需要实施的任何查询或逻辑吗?



我们将非常感谢您的帮助。



谢谢,

Suraj。

I have a table named property which contains one column (propertyNames). Table has around 75000 rows.

My Task :
I want to get all rows in json files. Each of json file should contain 6 records only but alphabetically.

For examples:
a.json should contain records starts with a.
aa.json should contain records starts with aa.
ab.json should contain records starts with ab.
harry.json should contain records starts with harry.

this all I wanted to do for fast search in my application. When user type some words in search box than auto complete will look for matched json file and display records from it. some kind of technique is used for IMDB search. I am trying to apply the same using static json files.

How does the IMDB search work so fast?

Problem :
So as I said I have 75000 records in table with one column,how do I create small sets of records (datatable with 6 records each) so I can convert that into json files via my applications.

I have tried this using like
for example :
select * from property where propertyNames like 'a%'
I got 3000 records from 75000 which starts with a.
but i dont want 3000 records should contain in one json file. so again I tried with like 'a%'
so I got 19 records. again tried with like 'ab%' got 80 records.

So, this all I have done only for a. still I don't get a desire result (6 each). Method I am using right now to get desire results which is very time consuming.

How can I get this records? Is there any logic I need to apply? can you please share any query or logic I need to implement?

Your help will be highly appreciated.

Thanks,
Suraj.

推荐答案

对您的查询进行以下更改。

Make following changes to your query.
SELECT TOP 6 * FROM [Property] WHERE [propertyNames] LIKE 'a%'



您将肯定会得到6条记录。


You will definitely get 6 records of each.


这篇关于如何按字母顺序将行排序为小结果集。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆