Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted
Updated 30-Aug-14 21:22pm
v2

1 solution

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

You will definitely get 6 records of each.
 
Share this answer
 
Comments
surajsurve 31-Aug-14 4:07am    
Thanks a lot for you answer but I want a dynamic query, Which will give me all the 75000 records sorted alphabetically in min 6 or max 10 each.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900