Android Question Looking for SQL statement...

Discussion in 'Android Questions' started by Cenny, May 11, 2015.

  1. Cenny

    Cenny Member Licensed User

    I am looking for a sql statement that gives me records where the fieldnames are in alphabetical order

  2. DonManfred

    DonManfred Expert Licensed User

    select fieldA,fieldB,[...] FROM table;
    Dont use *. Add all Fields by it names and aplabetical order into the query....
    There is no buildin function to get the fields ordered.
  3. Cenny

    Cenny Member Licensed User

    Thanks for the reply

  4. eurojam

    eurojam Well-Known Member Licensed User

    I don't think, that you can manage it in one step. First you have to query the fieldnames from your table. There are different sql statements in the different database systems for that, like in sqlite:
    PRAGMA table_info(mytable);
    in the second step you iterate through the result of the first query and build your select statement
    thedesolatesoul likes this.
  5. Cenny

    Cenny Member Licensed User

    I have solved it by extracting the fieldnames from the table, put them in a list, sorted it and used the list to build a new sql select statement.
    Works fine.
    Thanks for your suggestions.

    DonManfred likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice