Re: [PHP-DB] Add or Subtract

2006-01-19 Thread Julien Bonastre

Thats not even a docs question..


Thats a "have you ever even sat down at a single teaching of SQL 
principles or read ANY basic SQL material at all" question.



Really man. UPDATE is one of the four most common SQL standard functions 
you will and should know quite well.


SELECT, INSERT, UPDATE, DELETE


I'm not having a go here, but maybe you should checkout like a basics of 
mysql e-book or something, I've landed on some goodies in the past and 
they're just fantastic, I've ended up mastering SQL query construction 
like spelling my name now. All shapes sizes, constraints of queries and 
where and how to use certain functions, where to use what, aggregate 
functions, stats, subqueries, multiple tables,transactional locking, etc 
etc etc its so exciting, really.




Enjoy!!


---oOo--- Allowing users to execute CGI scripts in any directory should 
only be considered if: ... a.. You have no users, and nobody ever visits 
your server. ... Extracted Quote: Security Tips - Apache HTTP 
Server ---oOo--- --oOo---oOo-- Julien Bonastre 
[The_RadiX] The-Spectrum Network CEO ABN: 64 235 749 494 
[EMAIL PROTECTED] 
www.the-spectrum.org --oOo---oOo-- 
- Original Message - 
From: "David Robley" <[EMAIL PROTECTED]>

To: 
Sent: Thursday, January 19, 2006 10:36 PM
Subject: Re: [PHP-DB] Add or Subtract


On Thu, 19 Jan 2006 22:55, Ed wrote:

I've been considering doing a little project for my community site
which allow people to sell and buy players ... They would have a limit
of 2,000,000 upon sign up .. However i'm not sure how i'd update this
figure 

Say player sells for example Alan Shearer for £300,000 he'd then have
2,300,000 how would i make it add to whats in the db already? same 
goes

for if he was sold and it went down to 1,700,000.

Ed


You haven't read the mysql docs much, I guess. Assuming you are storing
your limit as an integer:

UPDATE table SET value = value + $newamount WHERE [something to identify
the record to be updated]

where $newamount is the positive or negative value of the increase 
passed

in from wherever.


Cheers
--
David Robley

Press any key to continue or any other key to quit...

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.375 / Virus Database: 267.14.20/234 - Release Date: 18/01/2006

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Add or Subtract

2006-01-19 Thread David Robley
On Thu, 19 Jan 2006 22:55, Ed wrote:
> I've been considering doing a little project for my community site
> which allow people to sell and buy players ... They would have a limit
> of 2,000,000 upon sign up .. However i'm not sure how i'd update this
> figure 
>
> Say player sells for example Alan Shearer for £300,000 he'd then have
> 2,300,000 how would i make it add to whats in the db already? same goes
> for if he was sold and it went down to 1,700,000.
>
> Ed

You haven't read the mysql docs much, I guess. Assuming you are storing 
your limit as an integer:

UPDATE table SET value = value + $newamount WHERE [something to identify 
the record to be updated]

where $newamount is the positive or negative value of the increase passed 
in from wherever. 


Cheers
-- 
David Robley

Press any key to continue or any other key to quit...

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php