Re: Figuring out the difference in value between 2 fields

2007-06-06 Thread Baron Schwartz
But beware unsigned math, if your columns are unsigned: create table t( a int unsigned, b int unsigned); Query OK, 0 rows affected (0.00 sec) mysql> insert into t(a, b) values(0, 100); Query OK, 1 row affected (0.00 sec) mysql> select a-b from t; +--+ | a-b

Re: Figuring out the difference in value between 2 fields

2007-06-06 Thread Peter Bradley
Ysgrifennodd Jason Pruim: Okay, so I have been gooling all over trying to figure this out. I'm sure it's easy enough to do, but I can't seem to find it. All I want to do is figure out the difference between 2 fields. IE: Field 1= 20 Field 2 =10 Difference between Field 1 & 2 is: 10 Any ideas?

Re: Figuring out the difference in value between 2 fields

2007-06-06 Thread Dan Buettner
If they're both numeric fields, then it's as easy as: SELECT field1-field2 AS difference FROM table; and if you always want a positive number: SELECT ABS(field1-field2) AS difference FROM table; HTH, Dan On 6/6/07, Jason Pruim <[EMAIL PROTECTED]> wrote: Okay, so I have been gooling all over t

RE: Figuring out the difference in value between 2 fields

2007-06-06 Thread Chris Boget
> Okay, so I have been gooling all over trying to > figure this out. I'm sure it's easy enough to do, > but I can't seem to find it. > All I want to do is figure out the difference between > 2 fields. IE: > Field 1= 20 > Field 2 =10 > Difference between Field 1 & 2 is: 10 > Any ideas? Umm, basi