Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Selecting all columns but one

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have about 30+ columns in my table. I want to select all columns but one column (which has to come from another table).
Do I have to specify each column name in the select clause or is there an easier and a better way of doing it?

All help appreciated.

Harsha
[ August 26, 2005: Message edited by: Harsha Pherwani ]
 
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I know, you can't create a query that specifies all-columns-except-for-one, or anything like that. So yes: in your case I believe you need to specify each of the columns you want.
 
Harsha Pherwani
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Stephen.

What I have done to get around this is:
In the select I get all columns i.e. * from the main table, and I select the column I want from another table and the alias name for this column is same as the column name I want to exclude.

When I execute the query in the database it gives me both the columns in the data output; but with JDBC while retrieving the values, when I invoke getString("<alias_name>") it gives me the value of the column from the second table. Thats what I need so my problem gets solved.
 
Ranch Hand
Posts: 158
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi harsha

Why dont you use column index rather column name. like If you use rs.getString(1) and rs.getString(3) it will always give you the required column data rather the same you are getting now.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic