How do i LIMIT the in Access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • werks
    New Member
    • Dec 2007
    • 218

    #1

    How do i LIMIT the in Access

    Hi there. how can i limit the value of records in Access. Is there a LIMIT function in Access like in MySQL? tnx in advance..


    Better Than Yesterday ^^
  • MindBender77
    New Member
    • Jul 2007
    • 233

    #2
    Originally posted by werks
    Hi there. how can i limit the value of records in Access. Is there a LIMIT function in Access like in MySQL? tnx in advance..


    Better Than Yesterday ^^
    When you say "limit the value of records" are you talking about limiting the number of records returned or specifically querying records greater than X?

    Bender

    Comment

    • werks
      New Member
      • Dec 2007
      • 218

      #3
      Yes i only want to get the 5 out of 10 records..

      Comment

      • werks
        New Member
        • Dec 2007
        • 218

        #4
        can i accomplish this using a query?

        Comment

        • MindBender77
          New Member
          • Jul 2007
          • 233

          #5
          Originally posted by werks
          Hi there. how can i limit the value of records in Access. Is there a LIMIT function in Access like in MySQL? tnx in advance..


          Better Than Yesterday ^^
          I believe this should work:
          [code=sql]
          Select Top 5 Field1, Field2 from Table1 group by Field1
          [/code]
          Last edited by MindBender77; Feb 11 '08, 03:17 PM. Reason: SQL Correction

          Comment

          • werks
            New Member
            • Dec 2007
            • 218

            #6
            Could you give me the Exact sample cause im getting an error..

            Is my code wrong?

            Code:
            SELECT * FROM qryOPAC WHERE Title='Kenneth' Fetch First 5 Rows Only

            Comment

            • MindBender77
              New Member
              • Jul 2007
              • 233

              #7
              Originally posted by werks
              Could you give me the Exact sample cause im getting an error..

              Is my code wrong?

              Code:
              SELECT * FROM qryOPAC WHERE Title='Kenneth' Fetch First 5 Rows Only
              My apologies, "Fetch" only works in DB2 sql. Access uses "TOP"
              [code=sql]
              select top 5 * from qryOPAC where title='Kenneth'
              [/code]

              Generic SQL Formate:
              [Code=sql]
              SELECT TOP 5 Table1.* FROM Table1;
              [/code]



              Bender

              Comment

              • werks
                New Member
                • Dec 2007
                • 218

                #8
                tnx Bender! it work!

                I have another question. can i get the remaining results in my query after using the TOP 5 OR it only limit itself to 5?

                Comment

                • MindBender77
                  New Member
                  • Jul 2007
                  • 233

                  #9
                  Originally posted by werks
                  tnx Bender! it work!

                  I have another question. can i get the remaining results in my query after using the TOP 5 OR it only limit itself to 5?
                  Unfortunately, I believe it limits itself to 5? You can research further though. In the query designer, right click anywhere in the gray area around your table box. Then click on Properties.

                  Bender

                  Comment

                  • werks
                    New Member
                    • Dec 2007
                    • 218

                    #10
                    Hi Bender could you look at my query? it seems that theres something wrong with it. cause it doesn't return any output..

                    Code:
                    SELECT TOP 5 qryOPAC.* FROM qryOPAC WHERE Title LIKE '%kenneth%'

                    Comment

                    • MindBender77
                      New Member
                      • Jul 2007
                      • 233

                      #11
                      Originally posted by werks
                      Hi Bender could you look at my query? it seems that theres something wrong with it. cause it doesn't return any output..

                      Code:
                      SELECT TOP 5 qryOPAC.* FROM qryOPAC WHERE Title LIKE '%kenneth%'
                      The problem is in your where clause:
                      [CODE=sql]SELECT TOP 5 qryOPAC.* FROM qryOPAC WHERE Title LIKE "*kenneth*"
                      [/CODE]

                      Use * with Like.

                      Bender

                      Comment

                      • werks
                        New Member
                        • Dec 2007
                        • 218

                        #12
                        Thanks Bender for your help ^^


                        Kenneth

                        Comment

                        Working...