I'm using the select query to select a particular record from the table by name. The table consists of more than 25000 records.
Table format is
|rcode|rname|vcode|vname|div_sec|ofrn|phone|dat|
Also, it may contains more than one record with the same name.. I'm using the following query
ResultSet rs=stmt.executeQuery("select * from newfarmer where rname='"+get+"'");
if(rs.next())
{
rcode=rs.getString("rcode");
out.print(rcode);
out.print(" ");
}
I have to find out the rcode of the given rname. Now the problem by using the above query is that, If I search for record with name "kannan" the table contains 6 records with the name "kannan" as
10001 kannan
10089 kannan
11826 kannan
12241 kannan
12389 kannan
19926 kannan
Now, my query only fetched the first record and give result as rcode="10001"
If I use
while(rs.next())
{
rcode=rs.getString("rcode");
out.print(rcode);
out.print(" ");
}
it will print only the last record as rcode="19926". Suppose I want to fetch record for "kannan" with rcode 12241, how can I modify the query to get the record? Note that I have to use only rname to fetch the details.
Is there any solution to this problem? Someone help me please