Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2006
    Posts
    33

    Unanswered: Exclude one column

    Hi there,

    It sounds lazy, but I just wonder instead of listing all the columns, can I select all but exclude one column in select statement?


    Thanks

  2. #2
    Join Date
    Jul 2006
    Location
    Pune , India
    Posts
    433
    ha ha ha
    i dont think so...

    regards
    another lazydba

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by jinsezh
    ... can I select all but exclude one column in select statement?
    yes, by listing only the columns that you want
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Try "select *-1 from mytable where..." - this just might work...
    ---
    "It does not work" is not a valid problem statement.

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by n_i
    Try "select *-1 from mytable where..." - this just might work...
    that's pretty funny

    but april 1st is still quite a ways down the road...

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Jan 2003
    Posts
    1,605
    Quote Originally Posted by n_i
    Try "select *-1 from mytable where..." - this just might work...
    But this only works if the last column is omited.


    Ok, get serious:
    You can write an SQL from catalog table to get all columns:
    db2 select colname from syscat.columns where tabschema='schema' and tabname='TEST'

    Hope this helps,
    Grofaty

  7. #7
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    It is good style anyways to list columns explicitly and not rely on "SELECT *".

Posting Permissions

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