How can I count dynamically the rows of a table?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Konstantinos_Kopanias
Posted On:   Tuesday, December 6, 2005 10:41 AM

Hello to all. Please check the following code: resultSetSorted=statement.executeQuery("SELECT COUNT(*) FROM "+tableNew); while(resultSetSorted.next()){ tmp2=resultSetSorted.getInt(1);} for(tmp=1;tmp resultSetSorted=statement.executeQuery("SELECT * FROM "+tableNew+" LIMIT 0,1"); while(resultSetSorted.next()){ tmpString=resultSetSorted.getString("words");} if(tmpString.length()>0){ countInnerTable++; resultSetSorted=statement.executeQuery("SELECT * FROM "+tableNew+" WHERE "+tableNew+".words=""+tmpString+"""); while(resultSetSor   More>>

Hello to all. Please check the following code:


resultSetSorted=statement.executeQuery("SELECT COUNT(*) FROM "+tableNew);

while(resultSetSorted.next()){

tmp2=resultSetSorted.getInt(1);}

for(tmp=1;tmp

resultSetSorted=statement.executeQuery("SELECT * FROM "+tableNew+" LIMIT 0,1");

while(resultSetSorted.next()){

tmpString=resultSetSorted.getString("words");}

if(tmpString.length()>0){

countInnerTable++;

resultSetSorted=statement.executeQuery("SELECT * FROM "+tableNew+" WHERE "+tableNew+".words=""+tmpString+""");

while(resultSetSorted.next()){

wrGen.write(""+countInnerTable+" "+resultSetSorted.getString("words")+"
");

}

}//end of if

statement.executeUpdate("DELETE FROM "+tableNew+" WHERE "+tableNew+".words=""+tmpString+""");

}//end of for



As you can see, I am counting all rows in the table, then run a for() up to the total of rows. But inside this for I have to delete some rows.

Is there a more elegant way to do it?

Thanks

   <<Less

Re: How can I count dynamically the rows of a table?

Posted By:   Almagest_FUTT  
Posted On:   Wednesday, December 7, 2005 07:41 AM

I fail to understand your code (please format it using
's), could you please explain what you do ? Some kind of sorting, isn't it ?
About | Sitemap | Contact