How to solve the SELECT TOP 1 statement in Access actually returns multiple records?

zhaozj2021-02-16  51

How to solve the SELECT TOP 1 statement actually returns multiple records?

Brief description: How to solve the SELECT TOP 1 statement actually returns a number of records issues

problem:

How to solve the SELECT TOP 1 statement actually returns multiple records? Select Top 9 Title, ID, Hit from Article Where Datediff ('h', [showdateb], now ()> = 0 Correctly display the first 9 Select Top 9 Title, ID, Hit from Article Where Datediff ('H' [Showdateb], now ()> = 0 ORDER BY HIT DESC will become all displayed ??? Only 4 values. Many 0 isn't this less than the nine, will it be taken out? How to solve it??? SQL Server does not have this problem

Reply:

Again again, Jet SQL is not a T-SQL statement. Jet SQL will return a repetition value, that is, if the field of Order By is 0, a total of 100 records, even if you return to records with SELECT TOP 1, it also returns 100 records because Jet DB is not from In these 100 records, it is judged in the order, and only 100 will be returned. To resolve this issue, you can create an automatic number field (ID), then use

SELECT TOP 1 A, ID from Tablename Order By A, ID

Http://access911.net webmaster collection

转载请注明原文地址:https://www.9cbs.com/read-24493.html

New Post(0)