In my servlet, I am doing a query of one table bringing back the data with
the method dataResultSet1.getString() then using what I get back to look for
a match in another table using the sql LIKE syntax. I just want to count the
matches from my first table that match my second table. I interate through
them using an outer and innner while statement.
- Should I be using sql COUNT and if so, how do I get the count into a
variable I can use in my servlet?
- What other options do I have?
Sincerely,
Tom Kochanowicz
Here is what I have so far....
// Outer loop checks for email & phrase.
while(dataResultSet1.next()){
//if(dataResultSet1.getString("Email").trim().equals("[EMAIL PROTECTED]
t")){
//System.out.println("THE PHRASE IS " +
dataResultSet1.getString("Phrase").trim());
String phrase = dataResultSet1.getString("Phrase").trim();
String email = dataResultSet1.getString("Email").trim();
// Inner loop checks if the Phrase found above matches any of
the WhatAdSays01 info.
stmt2 = dbConnection.createStatement();
dataResultSet2 = stmt2.executeQuery("select WhatAdSays01 from
AdInfoView WHERE WhatAdSays01 LIKE '%" + phrase + "%'");
while(dataResultSet2.next()){
// Count the number of matches.
countForMatches++;
///outputToBrowser.println(" WE HAVE A MATCH" +
countForMatches);
}
outputToBrowser.println("WE HAVE FOUND " + countForMatches + "
matches for your search word(s) " + phrase + " ");
count++;
}
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html