Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    358
    Thanks
    2
    Thanked 0 Times in 0 Posts

    i get more record when i use "SELECT Top 1 * from..." in Access with ASP??!!

    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?
    Thanks.
    =====================================================
    From NinjaTurtle
    ++http://ohmygoh.blogspot.com|http://technology.ohmygoh.com++

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    The sunny side of the Alps
    Posts
    230
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can you post the code you use for showing the retrieved record?

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    478
    Thanks
    0
    Thanked 2 Times in 2 Posts
    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.
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Posts
    358
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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;

    instead of

    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.
    Last edited by NinjaTurtle; 10-04-2005 at 07:44 AM.
    Thanks.
    =====================================================
    From NinjaTurtle
    ++http://ohmygoh.blogspot.com|http://technology.ohmygoh.com++


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •