Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL Results

 
Pol Appan
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I want to display results in a sql in the format mentioned below.

Category is a column in one table and answrs are in another table and id is the join to connect these tables.

Category 1
Answr 1
Answr 2
Answr 3

Category 2
Answr 1
Answr 2
Answr 3
so forth.
 
stu derby
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Pol Appan
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot.
 
Pol Appan
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can return more than one string in the same method. i.e. I want category and answr to be return?

How multiple return possible in java?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34837
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cosmos,
You can create an object and put those fields in the object. Or if for reason you can't create a new object, you can use a HashMap with the name as key and the value what you want to return.
 
Pol Appan
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could kindly give an example of the same code?

Thanks
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For HashMap




For Object you need to create a Value Object to hold these values



Then use the value object in your code




Then in your code you can use list as below




Shailesh
[ June 12, 2006: Message edited by: Shailesh Chandra ]
 
Pol Appan
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot and much appreciated.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic