If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Exclude one column

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-15-07, 21:29
jinsezh jinsezh is offline
Registered User
 
Join Date: Aug 2006
Posts: 33
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
Reply With Quote
  #2 (permalink)  
Old 01-16-07, 01:51
rahul_s80 rahul_s80 is offline
Registered User
 
Join Date: Jul 2006
Location: Pune , India
Posts: 433
ha ha ha
i dont think so...

regards
another lazydba
Reply With Quote
  #3 (permalink)  
Old 01-16-07, 05:10
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #4 (permalink)  
Old 01-16-07, 12:21
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Try "select *-1 from mytable where..." - this just might work...
Reply With Quote
  #5 (permalink)  
Old 01-16-07, 12:50
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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...

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #6 (permalink)  
Old 01-17-07, 01:49
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
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
Reply With Quote
  #7 (permalink)  
Old 01-17-07, 07:04
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
It is good style anyways to list columns explicitly and not rely on "SELECT *".
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On