These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: how to apply math function if field is null
PostPosted: Wed Apr 18, 2007 9:25 am 
Newbie

Joined: Wed Apr 18, 2007 9:12 am
Posts: 1
Hibernate version:3.2.RC4

MySQL 5

Hi, I have one tricky problem, MySQL table Polloftheday has next fields,
answer1_num (integer), answer2_num(integer), answer3_num(integer) and
answer4_num (integer).

Poll can have minimum two questions and max. four questions.

I want to add these fields like answer1_num, answer2_num, etc. to get total votes.

Problem is that some of these fields can be null and I am for math function
answer1_num+answer2_num+answer3_num+answer4_num getting null if any of fields is null. Later I want to sort by that calculated colum but that would be my next question.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 18, 2007 12:05 pm 
Regular
Regular

Joined: Thu Dec 22, 2005 7:47 am
Posts: 62
Location: Czech Republic
i would do this "math" in Java -- it is easy enough to iterate and test for null or you may try to use the SQL directly.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.