How do I solve a problem where the SELECT top 1 statement in Access actually returns multiple records?

Source: Internet
Author: User
Tags return
access|select| Solve | problem | statement
How do I solve a problem where the SELECT top 1 statement actually returns more than one record?




Brief description: How to solve the problem that the SELECT top 1 statement actually returns multiple records




Problem:

How do I solve a problem where the SELECT top 1 statement actually returns more than one record?


SELECT Top 9 Title,id,hit from Article WHERE DATEDIFF (' h ', [Showdateb],now ()) >=0
The first 9 can be displayed correctly

SELECT Top 9 Title,id,hit from Article WHERE DATEDIFF (' h ', [Showdateb],now ()) >=0 order by hit DESC
It's all displayed.

???

Only 4 values. A lot is 0.

Is this less than nine will be all taken out?

How to solve it???
There is no such problem in SQL Server






Reply:

Again, JET SQL is not a T-SQL statement.
Jet SQL Returns a duplicate value, that is, if the field in a table is 0, a total of 100 records, even if you use select top to return records, it also returns 100 records, because JET DB does not have the order of precedence in these 100 records, can only return Back to 100 articles. To resolve this issue, you can create an AutoNumber field (ID), and then use the
Select top 1 A,id from TableName ORDER by A,id

HTTP://ACCESS911.NET Webmaster Collection


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.