View Full Version : i get more record when i use "SELECT Top 1 * from..." in Access with ASP??!!
09-27-2005, 03:10 PM
SELECT TOP 1 * FROM part WHERE partid='IT' ORDER BY partdate DESC
in my database i have 2 same date but differet partid records, after execute it out, it shows 2 records in the HTML???
if i order by partid(unique) it will displace correctly. but if sort by date(smae date) ten i will get more records..... WHY?
how this happen?
09-30-2005, 07:00 AM
Can you post the code you use for showing the retrieved record?
10-04-2005, 05:38 AM
You are correct that additional records are shown if they are what you and I might consider to be a "tie." Thus TOP 10 sorted on date descending could show many more than 10 records if there are several records with the 10th highest date.
10-04-2005, 07:41 AM
bostjank, even u query from MS Access oso u will get te same result. so it is not a problem of using ASP code on displaying the records.
ya, so i just added one more field as 2nd criteria(unique key) then it works well.
SELECT TOP 1 * FROM part WHERE partid='IT' ORDER BY partdate DESC, partID;
SELECT TOP 1 * FROM part WHERE partid='IT' ORDER BY partdate DESC;
it is not like mySQL we can use "LIMIT" instead of using "TOP" in MS ACCESS.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.