Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 displaying info in the correct order

Author  Topic 

token
Posting Yak Master

133 Posts

Posted - 2006-01-12 : 11:03:40
hi guys,

I was wondering if anyone knew how to get records in a table to display in a correct order. I know this sounds simple on face value, but the problem scenario is this:

You make laptops. Each laptop has a specification that is entered into a seperate table called Specificions. Each feature (e.g. CPU, RAM) is entered as a seperate record in the table like below:

----------------------------------------
ProductID || FeatureID || Feature
1            1             AMD Athlon 64
1            2            1GB RAM
----------------------------------------

This database is connected to a webpage that displays the specifications of each laptop. The specifications should be displayed in a particular order on the webpage (e.g. CPU first, then RAM) so I enter them into the Specifications table in the correct order.

However sometimes you forget to enter a feature in, and when you go back you can't "insert" a record "above" a previous record so that the correct display order is maintained. Thus I have to insert it as a new record at the "bottom" of the table. If that forgotton feature was the CPU, then the webpage shows the CPU at the bottom of the page instead of at the top of the page.

Am I doing this thing correctly or is there a much easier way to do this? I would have designed the table with fields that said "CPU", "RAM" etc because they are needed for ALL laptops. However, some laptops have features like a TV Tuner which don't fit into any particular field.

If you took the time to read my post, I thank you cordially even if you don't reply!

Best Wishes,
Token


Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-01-12 : 11:30:31
U can keep a sepeate table (or may be a sepearate column in items table) to keep the location and that has to be maintained at the time of inserting / deleting records.

When a new item is to be added
Determine the valuse of the location by a function
Increment each of those more than that location number, by 1
Insert that record with that location number.

in to the middle value of that field (or table-column) those higher than that should be incremented

Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-01-12 : 12:06:46
Create a [Feature Type] table, and add a reference to [Feature Type] in the Feature table.

In the [Feature Type] table, add a column like [Screen Sort Order] int, and populate it with the order that you would like the feature to appear.

Join to this table when you return your result and order by [Screen Sort Order].




CODO ERGO SUM
Go to Top of Page
   

- Advertisement -