Need help in a java program or rather SQL or maybe the problem is in netbeans. Actually I don't know what is the actual problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 9

Need help in a java program or rather SQL or maybe the problem is in netbeans. Actually I don't know what is the actual problem

I have made a java project using netbeans and derby, with the database in netbeans itself. I don't know why but The SQL count function is not working as expected. In the program: e.g: "SELECT COUNT(*) FROM TABLE_NAME" works and gives the result in the resultset correctly while "SELECT COUNT(AGE) FROM TABLE_NAME WHERE AGE='youth' AND CONDITION='yes' " doesn't work and there is no data in resultset available. Why???? In the Netbeans' Services: I also tried running the sql query directly on the database from the services on netbeans but here even "SELECT COUNT(*) FROM TABLE_NAME" doesn't return anything (so how am I getting the result for this in my program?!!). But "SELECT * FROM TABLE_NAME" works. The count is not working at all. Why?? Kindly help me and thank you for going through such a long question. Reached ETC(End of thinking Capacity)

5th Apr 2017, 1:07 PM
Saumya
Saumya - avatar
6 Answers
+ 8
@cahya, yes I've tried that too but still not working.
5th Apr 2017, 3:02 PM
Saumya
Saumya - avatar
+ 7
@Vimal, presently I am not that active on SoloLearn + coming back after a couple of month, I realised that I need to revise the concepts and also my exams are going on now so that's why.
4th Dec 2017, 6:41 AM
Saumya
Saumya - avatar
+ 6
@saumya okay dear I can understand 😉
4th Dec 2017, 9:01 AM
Vimal Tirkey
Vimal Tirkey - avatar
+ 5
why you disabled the challenge button 😗😗?
3rd Dec 2017, 7:25 PM
Vimal Tirkey
Vimal Tirkey - avatar
+ 1
since you don't provide the script that related to your question, it's difficult to catch the problem. It's a lot of possibilities. cmiiw :)
5th Apr 2017, 3:09 PM
cahya dwiana sn
cahya dwiana sn - avatar
0
IMHO, was you tried to using 'field alias' for your COUNT(*) ? eg: SELECT COUNT(*) AS num_age FROM table_name WHERE age='youth' AND condition='yes' so you can refer to `num_age` to get number of record that match with your criteria (rather than refer to COUNT(*) that have no 'field' name) cmiiw :)
5th Apr 2017, 3:00 PM
cahya dwiana sn
cahya dwiana sn - avatar