Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9

Thread: select top

  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts

    select top

    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?

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    Code:
    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.

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts
    it wasn't it
    the error is:
    Too few parameters. Expected 1

  • #4
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    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

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.

  • #6
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    I've just run your exact query in an access db I created without any problems at all

  • #7
    Senior Coder TheShaner's Avatar
    Join Date
    Sep 2005
    Location
    Orlando, FL
    Posts
    1,126
    Thanks
    2
    Thanked 40 Times in 40 Posts
    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

  • #8
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    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.

  • #9
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •