View Full Version : select top

09-13-2005, 05:05 PM
select top 1 * ... works fine.
but this:
SELECT top 1 [id],[date],[title],[text],[author],[picTitle],[picFilename],[fileTitle],[fileFilename] FROM magazine OREDER by [dop]

returns error.
what's the problem?

09-13-2005, 05:11 PM
SELECT top 1 [id],[date],[title],[text],[author],[picTitle],[picFilename],[fileTitle],[fileFilename] FROM magazine OREDER by [dop]

if thats just a typo and not what you really have in your statement help us out by telling us what error you get.

09-13-2005, 05:14 PM
it wasn't it
the error is:
Too few parameters. Expected 1

09-13-2005, 05:54 PM
Are you using access for your db?
That message means one (or more) of the fields in your select query doesnt exist in the table

09-13-2005, 06:48 PM
I use access.
They do exist. The SELECT was there before I added the "top 1" - so this is the problem, but i don't know what's wrong with that.

09-13-2005, 07:55 PM
I've just run your exact query in an access db I created without any problems at all

09-13-2005, 08:19 PM
Nancy, he was able to run it with the * and he said it was fine. So if the db you created only has the fields he selected, then it'd run fine for you. The difference with him is that there are fields he is omitting, which gives the Top N problems. I'm not really that familiar with Top N, but I'm guessing that it's having a problem selecting the first result row due to the omission of whatever fields haven't been selected (which is why the error says "Too Few Parameters").


09-13-2005, 08:21 PM
I've tried several variations of the query on different databases selecting all or some of the fields by name and have been unable to recreate this issue.
Without seeing the database theres not much more we can do.

09-13-2005, 08:24 PM
i'm so sorry...
the difference was the top n AND the ORDER BY
and [dop] was a typo too...

problem solved... sorry bathering you with typos :o