mysql query using jdbc
- by S.PRATHIBA
Hi all,
I have the following table:
Service_ID feedback
31 1
32 1
33 1 1
I have the sample code to find the sum:
ResultSet res = st.executeQuery("SELECT Service_ID,SUM(consumer_feedback) FROM consumer5 group by Service_ID");
while (res.next())
{
int data=res.getInt(1);
System.out.println(data);
System.out.println("\n\n");
int c1 = res.getInt(2);
e[m]=res.getInt(2);
System.out.println("\n \n m is "+m+" e[m] is "+e[m]);
if(e[m]<0)
e[m]=0;
m++;
System.out.print(c1);
System.out.println("\t\t");
}
i have to get the output as
31 1
32 1
33 1
I am getting it.But for my project i have 34,35 also.I should get theoutput as
31 1
32 1
33 1
34 0
35 0