...

View Full Version : select top



ShMiL
09-13-2005, 04: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?

NancyJ
09-13-2005, 04: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.

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

NancyJ
09-13-2005, 04: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

ShMiL
09-13-2005, 05: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.

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

TheShaner
09-13-2005, 07: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").

-Shane

NancyJ
09-13-2005, 07: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.

ShMiL
09-13-2005, 07:24 PM
wow
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum