Monday, March 12, 2012

Retrieving Data from database

Hi,
I have relatively less experience to SQL. I had a question. Say I have to
display certain records on a datagrid. this datagrid is dependent on these
parameters.
suppose a user enters a partial value in a text box. eg: "12"
I make use of "like" feature(...partID like '12%') in the query and it
retrieved "3" records from the database.
using the resultset I have to retrieve 5 records prior and 5 records after
the "original" set of results(3)... and display the total records (5+3+5 = 13) on the datagrid.
whats the best way of doing this... I have no clue of how to do this... hope
I have conveyed my idea properly...
Place advice,
Stephen> using the resultset I have to retrieve 5 records prior and 5 records after
> the "original" set of results(3)... and display the total records (5+3+5 => 13) on the datagrid.
You need to define what "prior" and "after" mean. Perhaps you are used to
Excel or Access, but in SQL Server, a table is an unordered set of rows. To
obtain the 5 rows "before" and "after" a certain row, you need to tell us
how you determine which rows come before and after...
--
http://www.aspfaq.com/
(Reverse address to reply.)

No comments:

Post a Comment