dotConnect for MySQL Documentation
Devart.Data.MySql Namespace / MySqlSelectLimit Class
Members Example

In This Topic
    MySqlSelectLimit Class
    In This Topic
    Represents MySQL LIMIT clause. Represents MySQL LIMIT clause.
    Syntax
    'Declaration
     
    Public NotInheritable Class MySqlSelectLimit 
       Inherits Devart.Common.SelectStatementNode
    public sealed class MySqlSelectLimit : Devart.Common.SelectStatementNode 
    Example
    The following example shows how the LIMIT clause may be parsed in a MySqlSelectStatement.
    static void ParseLimit(string sql) {
    
      MySqlSelectStatement stmt = MySqlSelectStatement.Parse(sql, ParserBehavior.All);
    
      if (stmt.Limit != null)
      if (stmt.Limit.Offset != null)
        Console.WriteLine("Offset: {0}, Count: {1}", stmt.Limit.Offset.ToString(), stmt.Limit.Count.ToString());
      else
        Console.WriteLine("Count: {0}", stmt.Limit.Count.ToString());
      else
      Console.WriteLine("No limit found");
    }
    
    ....
    
    ParseLimit("select * from dept limit 3"); // Count: 3
    ParseLimit("select * from dept limit 2, 3"); // Offset: 2, Count: 3
    ParseLimit("select * from dept limit 3 offset 2"); // Offset: 2, Count: 3
    
    ParseLimit("select * from dept limit :pCount"); // Count: :pCount
    ParseLimit("select * from dept limit :pOffset, :pCount"); // Offset: :pOffset, Count: :pCount
    ParseLimit("select * from dept limit :pCount offset :pOffset"); // Offset: :pOffset, Count: :pCount
    
    ParseLimit("select * from dept limit @pCount"); // Count: @pCount
    ParseLimit("select * from dept limit @pOffset, @pCount"); // Offset: @pOffset, Count: @pCount
    ParseLimit("select * from dept limit @pCount offset @pOffset"); // Offset: @pOffset, Count: @pCount
    
    ParseLimit("select * from dept limit ?"); // Count: ?
    ParseLimit("select * from dept limit ?, ?"); // Offset: ?, Count: ?
    ParseLimit("select * from dept limit ? offset ?"); // Offset: ?, Count: ?
    Private Shared Sub ParseLimit(ByVal sql As String)
      Dim stmt As MySqlSelectStatement = MySqlSelectStatement.Parse(sql, 63)
      If (Not stmt.Limit Is Nothing) Then
        If (Not stmt.Limit.Offset Is Nothing) Then
          Console.WriteLine("Offset: {0}, Count: {1}", stmt.Limit.Offset.ToString, stmt.Limit.Count.ToString)
        Else
          Console.WriteLine("Count: {0}", stmt.Limit.Count.ToString)
        End If
      Else
        Console.WriteLine("No limit found")
      End If
    End Sub
    
    ...................
    
    Module1.ParseLimit("select * from dept limit 3")
    Module1.ParseLimit("select * from dept limit 2, 3")
    Module1.ParseLimit("select * from dept limit 3 offset 2")
    
    Module1.ParseLimit("select * from dept limit :pCount")
    Module1.ParseLimit("select * from dept limit :pOffset, :pCount")
    Module1.ParseLimit("select * from dept limit :pCount offset :pOffset")
    
    Module1.ParseLimit("select * from dept limit @pCount")
    Module1.ParseLimit("select * from dept limit @pOffset, @pCount")
    Module1.ParseLimit("select * from dept limit @pCount offset @pOffset")
    
    Module1.ParseLimit("select * from dept limit ?")
    Module1.ParseLimit("select * from dept limit ?, ?")
    Module1.ParseLimit("select * from dept limit ? offset ?")
    Inheritance Hierarchy

    System.Object
       Devart.Common.SelectStatementNode
          Devart.Data.MySql.MySqlSelectLimit

    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also