Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How to subtract negative values
Old 04-05-2005, 06:53 AM How to subtract negative values
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
So using select sum(points) as score from this will also add a minus value.

How can I get around this and have it subtract that value.

Cheers

Ibbo
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Linux user #349545 :
(GNU/Linux)iD8DBQBAzWjX+MZAIjBWXGURAmflAKCntuBbuKCWenpm XoA7LNydllVQOwCf
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
 
Register now for full access!
Old 04-05-2005, 08:14 AM
ibbo's Avatar
Super Spam Talker

Posts: 880
Location: Leeds UK
Trades: 0
Scrap that,

Weird DB behaviour when i use type int it passes it as a string, but when i use type integer I get an int. So now sum actually subtracts (by adding) negative numbers) which it would not do as an int.

Bizarre

Ibbo
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Linux user #349545 :
(GNU/Linux)iD8DBQBAzWjX+MZAIjBWXGURAmflAKCntuBbuKCWenpm XoA7LNydllVQOwCf
ibbo is offline
Reply With Quote
View Public Profile Visit ibbo's homepage!
 
Old 04-05-2005, 04:03 PM
Experienced Talker

Posts: 36
Trades: 0
Maybe you set the column to be unsigned ?

Code:
mysql> select version();
+-----------+
| version() |
+-----------+
| 4.0.20    |
+-----------+
1 row in set (0.01 sec)

mysql> create table t (t int default 0);
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t values (1),(2),(3),(-3);
Query OK, 4 rows affected (0.00 sec)
Records: 4  Duplicates: 0  Warnings: 0


mysql> select * from t;
+------+
| t    |
+------+
|    1 |
|    2 |
|    3 |
|   -3 |
+------+
4 rows in set (0.00 sec)

mysql> select sum(t) from t;
+--------+
| sum(t) |
+--------+
|      3 |
+--------+
1 row in set (0.00 sec)
tress is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to subtract negative values
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24038 seconds with 12 queries