|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Have you heard of SELECT TOP 10 * ?
In looking for a way to show only the top 10 records by date I found this. If you look at the code the record counting does the limt work. But why do they have "TOP 10 *" instead of just *. Does it serve a purpose?
URL mySQL = "SELECT TOP 10 * FROM tblScripts ORDER BY DateEntered DESC" |
|
#2
|
||||
|
||||
|
Quote:
It only returns the first 10 records and orders them by the DateEntered field. The TOP ?? only selects the first ?? records that match the query. If you just wanted to return the first 10 records from a database where the state was equal to "Missouri" you would write the query like this Code:
SELECT TOP 10 * FROM tableName WHERE state = 'Missouri' |
|
#3
|
|||
|
|||
|
Thanks
I guess the record count part was what was throwing me off . I just went and commented all that out and sure enough the top with a number works all alone. Not sure why that source would put the record count code in there too?
Learn something new every hour it seems. Thanks again |
|
#4
|
||||
|
||||
|
Can you do SELECT 10 to 20 * FROM table etc.?
I'd want to select the second grouping of 10 records from the database. |
|
#5
|
||||
|
||||
|
no, you would have to do a .move statement to select the next 10 records...basically the way db paging is done.
|
|
#6
|
||||
|
||||
|
I never use Access but rather MySQL. Is there an equivalent to Access's .move?
|
|
#7
|
|||
|
|||
|
Where do you put this code? before the recordset? I am using an access database. Will it work there? My query brings up 1784 responses and access can't handle that. I want to bring up the first 50 and then be able to click next and so on. Like with ebay when you look up guitar it brings up a lot of results and they are broken apart into many pages. Can you help me? make that happen?
Quote:
|
|
#8
|
|||
|
|||
|
Where does the code go.
OK but where do you put it? Right before the recordset function?
Quote:
|
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Have you heard of SELECT TOP 10 * ? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|