Announcement

Collapse
No announcement yet.

SC alternative for LIMIT in SQL

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • SC alternative for LIMIT in SQL


    When you only want a certain number of records to be loaded in the grid, you can achieve this without LIMIT. You need to have or create a specific column though to be able to do this.

    Example 1, when you have an auto_increment column named ID, and you only want the
    FIRST 3 records created to be displayed:

    Code:
    SELECT *
    FROM table tab
    WHERE 3 > ( select count(*)
          from table tab2
          where tab2.id < tab.id
         )

    Example, when you have an auto_increment column named ID, and you only want the
    LAST 3 records created to be displayed:

    Code:
    SELECT * 
    FROM table tab
    WHERE 3 > ( select count(1)
          from table tab2
          where tab2.id > tab.id
         )
    Change "3" to change the number of records to be displayed.
    If you need a specific range, you need 2 of these statements in the WHERE clause (using AND operator).

    You can also achieve this when you have only a datetime_created column that is unique in the table

    Note: when you don't specify an ORDER BY clause in the sql, Mysql orders your rows by default based on creation of the rows. It does not use any of your columns for this.


  • #2
    Re: SC alternative for LIMIT in SQL

    Not in SQLServer directly. It doesn't return a row counter so there is no way to say record Another piece of syntax I've forgot.Have to get my RAM refresh cycle adjusted.
    Online casino

    Comment


    • #3
      Re: SC alternative for LIMIT in SQL

      Why you dont use directly the clause LIMIT?

      Comment


      • #4
        Re: SC alternative for LIMIT in SQL

        gives an error in SC!

        Comment


        • #5
          Re: SC alternative for LIMIT in SQL

          there s an option in the grid.
          Pagination and Lines Per PAge.

          Comment


          • #6
            Re: SC alternative for LIMIT in SQL

            these options have a different purpose than the LIMIT clause.....

            LIMIT limits the number of rows returned. Pagination and Lines control the way the returned rows are presented (lay out). The do not limit the number of rows returned by the database.

            you should have known that.....

            Comment


            • #7
              Re: SC alternative for LIMIT in SQL

              Yes, LIMIT needs to be supported. Different from paginate.

              Regards,
              Scott.

              Comment


              • #8
                Did this ever get supported? I can't seem to figure a way to do it without an error.

                Comment


                • #9
                  I would never run critical data in Express if i had a "sharp" version of sql Server laying around period.

                  Comment

                  Working...
                  X