The Select top in the access application is invalid.

Source: Internet
Author: User

A long time ago, when I used ASP + ACCESS, I found that the select top SQL statement is invalid. No matter how many top SQL statements are available, the same statement is normal in SQL2000, at that time, I checked a problem about the top function in access, which had never been solved, so I was lazy to use the limitation.ProgramThe number of cycles is fixed.

Recently, I have rewritten the deep learning (ASP) URL navigation (www.deepteach.com) and carefully checked the information. It turns out that access has limited support for select top statements. If you want to use it, you must use order by after the top query statement, and the order by sorting field must be a non-repeated value, if there is a duplicate value, the top may be invalid and all records will be returned.
For example:

Select top 5 from Table order by gender. If there is a duplicate value in the "gender" field, all records may be displayed in the ACCESS database query. In this case, the top function is invalid, however, if there is no duplicate value in "gender", the top function is still effective. Therefore, to use the top function in access, check whether the order by field has duplicate values. For the sake of insurance, you can add a primary key: select top 5 from Table order by gender, ID

This problem can be prevented by using the primary key as a "non-repeating" safeguard !!

# ASP Column

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.