Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

handling multiple values in result set

Status
Not open for further replies.

lovinasd

Programmer
Jan 23, 2005
23
US
Hi,
i have a sql statment in the result set whose result is aan input to another sql statment.I am able to retreive one row but the next row is not retrieved the first result set is not getting executed..
eg.
rs=select distinct(name ) from sample;
this name is used in the next statment to retrive
rs2=select * from sample where name=name;
This execute the first row.
the nxt row there is a error in rs.next statment.
caould you tell me how can i retrivethe results from the resultset1
Do let me know
Thanks
 
why can't you write a sql statement like this

SELECT * FROM sampe WHERE name IN (SELECT DISTINCT(name) FROM sample)
 
You should make sure you are using MYSQL 5.0 before attempting to use the IN operator. At least, I think it's 5.0. I don't believe the earlier versions support it.

Nick Ruiz
Webmaster, DBA
 
Good point.

Another way to do it is to create a class for the sample table

public class Sample {
private int field1;
private string field2;

some getter and setter

}

* Create an array, list of the type Sample

* iterate through your object with a while loop and

while (object.hasnext() ) <-- check syntax here
{
select * from sample where name = current value of the object

}


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top