3 messages in com.mysql.lists.mysqlRe: Infinity as field value
FromSent OnAttachments
Scott Klarenbach29 Mar 2005 15:51 
Renato Golin29 Mar 2005 16:02 
Daniel Kasak29 Mar 2005 16:13 
Subject:Re: Infinity as field value
From:Daniel Kasak (dka@nusconsulting.com.au)
Date:03/29/2005 04:13:41 PM
List:com.mysql.lists.mysql

Scott Klarenbach wrote:

Is there a way to represent infinity in mysql?

I've got a range field in my GUI, which is "> x"...

if the user chooses this field, in the DB, I store it as:

id | from | to | other 2 | x | infinity | etc...

this is because there are situations of "< x" and "between x AND y", so from and to is the easiest way to store it...

I could make infinity default to 100,000,000 or some other number I know will never be reached, but it seems less elegant a solution...

If the user enters infinity, store a NULL value in the field. In your code, if you detect a NULL value, don't use a limit. ie don't say 'between x and y', but instead say something like:

where some_field > x and some_field < y

in the case where there are 2 values, or:

where some_field > x

in the case where a NULL value is detected in y, or:

where some_field < y

in the case where a NULL value is detected in x