File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Selecting all columns but one

 
Harsha Pherwani
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
Stephen Huey
Ranch Hand
Posts: 618
  • 0
  • Mark post as helpful
  • send pies
  • 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
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Anand Karia
Ranch Hand
Posts: 156
Java
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic