Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Select Particular Column values in sql without know the column name

 
prakasham selamban
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to get particular column values in sql table.For example if table has 10 columns i want to select the values of 4 to 10 column values. Here i dont know the column names because all columns are generated at a run time. i need help as soon as possible. I have searched in lot but i could not find the sql query.
 
Charbel Keyrouz
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After you execute your query and in the rs.next loop do the following:

Instead of calling the fieldname you can get the value by index of the column.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12147
31
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There also should be a way to query for the column names in your code. It would depend on what api you are using to connect/run against the DB.
 
prakasham selamban
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.

I want the sql query to select records
 
Charbel Keyrouz
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want the column names you can get them as follows:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic