Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

Populating a drop down list box

How can I populate a drop down list box with the last 10 entries in a column?
0
mpreuett
Asked:
mpreuett
  • 4
  • 2
  • 2
  • +3
1 Solution
 
odessaCommented:
Dorp down list in which program or tool?
0
 
mpreuettAuthor Commented:
Adjusted points to 500
0
 
mpreuettAuthor Commented:
On a web page that I want to use for a small questionaire on an intranet.  I use MS-SQL 6.5 and Netscape SuiteSpot Enterprise Server.
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
odessaCommented:
see coment to your previos Q
0
 
fox_doggCommented:
Well. You did not give much info.
What do you mean by last ten entries in a column.

If you mean the last ones added  you need to know the table.
Does it have a Identity column?
If so you could do something like:
select col from table where identity_column>(select max(identity_col)-10 from table)

Thus this would give you the last ten entered.

If using a timestamp field.
You can use the same code above exactly.
Replacing identiy_column with your timestamp_col name
However, this will give you the last ten columns that were changed!


If using a field that inserts the date . Use the same code and that column.

Hope that gives you a clue.
On SQL Server7. you can use the web assistant for HTML

With more information I can give you a better answer.

0
 
aliciaamCommented:
You may have to implement a stored procedure using cursors. It depends on how you want that information.
0
 
mpreuettAuthor Commented:
Here is exactly what I am trying to do.  I have a database with  some varchar columns.  Throuh a webpage on our intranet I am having people fill those in.  What I want to be able to do is put a drop down list box above each one of those fields populated with the last ten entries to the column for people to select and enter into the column without having to type it in.  I am using a timestamp field as the key.  I'm not having a problem inserting the info into the db, that's easy, I just don't know how to populate the dropdown box with the last ten entries.  What other information do i need to supply?
0
 
csalvesCommented:
Did you have tried to select the MAX. 10 Rowid's.

bye
0
 
aliciaamCommented:
If you use an identity column you can pinpoint the last row entered and then select while identity column last minus ten up to last with a while construct statement populate the results set.
Let me know if you need more info on identity or the while construct.
0
 
cognitionCommented:
You can also use the SET ROWCOUNT n. Where n is the number of rows to return. Then use SET ROWCOUNT 0, to return to the default. SET ROWCOUNT causes SQL server to stop processing a query afterr a certain number of rows have been returned. Note it also affects triggers and other SQL statements that occur until it is reset.

Using an identity column, may cause spurious results if rows are deleted, and the programming may be more complex.

SET ROWCOUNT 10

SELECT varchar
FROM Table
ORDER BY TimeStamp DESC

SET ROWCOUNT 0



0
 
mpreuettAuthor Commented:
Figured it out...  Thanks...
0
 
cognitionCommented:
I should have answered it then not commented!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now