Infinity as field value

2005-03-29 Thread Scott Klarenbach
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...

thanx,
Scott.

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Infinity as field value

2005-03-29 Thread Renato Golin
On Tuesday 29 March 2005 20:51, Scott Klarenbach wrote:
 Is there a way to represent infinity in mysql?

 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...

probably not the best but you could have two fields:

enum value_from { inf_neg, inf_pos, number },
int from,
enum value_to { inf_neg, inf_pos, number },
int to,

And if value is number you try to evaluate it, otherwise you use the 
constants.

You could also use 2147483647 and -2147483648 as being less uglier (but still 
ugly) as MaxInt.

--rengolin


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Infinity as field value

2005-03-29 Thread Daniel Kasak
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

-- 
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: [EMAIL PROTECTED]
website: http://www.nusconsulting.com.au

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]