+ Reply to Thread
Results 1 to 4 of 4

Thread: TOP 100

  1. #1
    Andrew Timmins
    Join Date
    Apr 2010
    Posts
    224
    Points
    27
    Answers Provided
    5


    0

    Default TOP 100

    Is there any SQL that is valid with the FGDB that will help me limit the results returned?
    I have tried TOP, LIMIT etc.. but none work.

    I could do it all in code, but I would rather retrieve only the records i need from the table.

    I am using the .NET wrapper.

    Thoughts?

    Drew

  2. #2
    Anthony Giles

    Join Date
    Aug 2011
    Posts
    819
    Points
    858
    Answers Provided
    130


    0

    Default Re: TOP 100

    Andrew,

    The help states the following:

    SELECT * FROM forms the first part of the SQL expression and is automatically supplied for you. Because you are selecting columns as a whole, you cannot restrict the SELECT to return only some of the columns in the corresponding table; thus, the hard-coded SELECT * syntax. For this reason, keywords like DISTINCT, ORDER BY, GROUP BY, and so on, cannot be used readily in a SQL query except when using subqueries.

    So what you could try and do (I must warn I have not tried this) is create a sub query that performs the limit then use the IN command to select out the records that you need, I.e:

    objectID IN (select objectID from (select objectID, column from 'table' where 'expression' order by 'column' limit 100))

    I say don't know if this will work but you never know

    Regards

    Anthony
    Last edited by ad_giles@hotmail.com; 10-14-2012 at 09:29 AM.

  3. #3
    Andrew Timmins
    Join Date
    Apr 2010
    Posts
    224
    Points
    27
    Answers Provided
    5


    0

    Default Re: TOP 100

    Thanks for the reply Anthony.

    I am able to get a full SQL query against the table using the below code..

    C#
    Code:
    string sql = "SELECT * FROM " + tableName
    RowCollection rows = geodatabase.ExecuteSQL(sql);
    From my knowledge the ExecuteSQL function will take raw valid SQL outlined in the doc's but the doc's do not show any way to limit the returned result (i.e LIMIT or TOP).

    Drew
    Last edited by cgishack; 10-14-2012 at 03:33 PM.

  4. #4
    Lance Shipman

    Join Date
    Oct 2009
    Posts
    331
    Points
    80
    Answers Provided
    14


    0

    Default Re: TOP 100

    TOP, LIMIT is not currently supported.
    Lance Shipman
    Geodatabase Product Engineer, File Geodatabase
    Esri

+ Reply to Thread

Posting Permissions

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