RE: [PHP-DB] Updating a record with math and division

2001-12-28 Thread David Piasecki

No...
UPDATE table SET value1 = value1 + increment

Or...
UPDATE table SET value1 = value1 * multiplier

...and so forth...

-Original Message-
From: Todd Williamsen [mailto:[EMAIL PROTECTED]] 
Sent: Friday, December 28, 2001 5:06 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Updating a record with math and division

Yes I got that much...

So it would be

UPDATE tblname SET value1 + $value1?
"David Piasecki" <[EMAIL PROTECTED]> wrote in message
000201c18ffd$a8187ec0$a6ccb0d8@pc5">news:000201c18ffd$a8187ec0$a6ccb0d8@pc5...
> You missed the first place you should have looked, the manual page on
> the 'UPDATE' syntax:
> http://www.mysql.com/doc/U/P/UPDATE.html
>
>
>
> -Original Message-
> From: Todd Williamsen [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 28, 2001 4:06 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] Updating a record with math and division
>
> That isn't the answer I was looking for...
>
> Since you are so nice could you be so kind in point
> me
> where these golden docs are?  I looked all over php.net and mysql.com,
> nada not only that the three books I have as well.  I am a newbie
at
> this, and do need a bit of hand holding thanks...
>
>
> "Miles Thompson" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]...
> >
> > Read the docs for the database in question. They will tell you what
is
> and
> is not allowed.
> > Miles Thompson
> >
> > On Friday 28 December 2001 06:26 pm, Todd Williamsen wrote:
> > > Ok
> > >
> > > So to update a record lets say...
> > >
> > > I have a current value of 150 and the new value will be 250 now
how
> would I
> > > total them to equal 400?
> > >
> > > I was thinking
> > >
> > > $sql = "UPDATE $table value1 =  value1 + ?
> > >
> > > is that correct?  how do you update it with simple math?
> > >
> > > What about division...
> > >
> > > take the current value in the database + the new value divided by
> another
> > > number, lets say another field
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
[EMAIL PROTECTED]
>
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Updating a record with math and division

2001-12-28 Thread Miles Thompson


Sarcasm be damned. If it's MySQL, then
http://www.mysql.com/doc/
and it's searchable.

I've worked with four SQL databases and they are similar enough that I always
have to refer to the docs when things stop working. Tricks in one don't necessarily 
work in the others. You need to look at the UPDATE command for whatever database
you are using.

To answer your question, many databases allow UPDATE set field = field + $var,
and it's a good idea to add a where condition, otherwise you change every record in 
the table

Miles Thompson

On Friday 28 December 2001 08:05 pm, Todd Williamsen wrote:
> That isn't the answer I was looking for...
>
> Since you are so nice could you be so kind in point me
> where these golden docs are?  I looked all over php.net and mysql.com,
> nada not only that the three books I have as well.  I am a newbie at
> this, and do need a bit of hand holding thanks...
>
>
> "Miles Thompson" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]...
>
> > Read the docs for the database in question. They will tell you what is
> > and
>
> is not allowed.
>
> > Miles Thompson
> >
> > On Friday 28 December 2001 06:26 pm, Todd Williamsen wrote:
> > > Ok
> > >
> > > So to update a record lets say...
> > >
> > > I have a current value of 150 and the new value will be 250 now how
>
> would I
>
> > > total them to equal 400?
> > >
> > > I was thinking
> > >
> > > $sql = "UPDATE $table value1 =  value1 + ?
> > >
> > > is that correct?  how do you update it with simple math?
> > >
> > > What about division...
> > >
> > > take the current value in the database + the new value divided by
>
> another
>
> > > number, lets say another field

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Updating a record with math and division

2001-12-28 Thread Todd Williamsen

Yes I got that much...

So it would be

UPDATE tblname SET value1 + $value1?
"David Piasecki" <[EMAIL PROTECTED]> wrote in message
000201c18ffd$a8187ec0$a6ccb0d8@pc5">news:000201c18ffd$a8187ec0$a6ccb0d8@pc5...
> You missed the first place you should have looked, the manual page on
> the 'UPDATE' syntax:
> http://www.mysql.com/doc/U/P/UPDATE.html
>
>
>
> -Original Message-
> From: Todd Williamsen [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 28, 2001 4:06 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] Updating a record with math and division
>
> That isn't the answer I was looking for...
>
> Since you are so nice could you be so kind in point
> me
> where these golden docs are?  I looked all over php.net and mysql.com,
> nada not only that the three books I have as well.  I am a newbie at
> this, and do need a bit of hand holding thanks...
>
>
> "Miles Thompson" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]...
> >
> > Read the docs for the database in question. They will tell you what is
> and
> is not allowed.
> > Miles Thompson
> >
> > On Friday 28 December 2001 06:26 pm, Todd Williamsen wrote:
> > > Ok
> > >
> > > So to update a record lets say...
> > >
> > > I have a current value of 150 and the new value will be 250 now how
> would I
> > > total them to equal 400?
> > >
> > > I was thinking
> > >
> > > $sql = "UPDATE $table value1 =  value1 + ?
> > >
> > > is that correct?  how do you update it with simple math?
> > >
> > > What about division...
> > >
> > > take the current value in the database + the new value divided by
> another
> > > number, lets say another field
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Updating a record with math and division

2001-12-28 Thread David Piasecki

You missed the first place you should have looked, the manual page on
the 'UPDATE' syntax:
http://www.mysql.com/doc/U/P/UPDATE.html



-Original Message-
From: Todd Williamsen [mailto:[EMAIL PROTECTED]] 
Sent: Friday, December 28, 2001 4:06 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Updating a record with math and division

That isn't the answer I was looking for...

Since you are so nice could you be so kind in point
me
where these golden docs are?  I looked all over php.net and mysql.com,
nada not only that the three books I have as well.  I am a newbie at
this, and do need a bit of hand holding thanks...


"Miles Thompson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
>
> Read the docs for the database in question. They will tell you what is
and
is not allowed.
> Miles Thompson
>
> On Friday 28 December 2001 06:26 pm, Todd Williamsen wrote:
> > Ok
> >
> > So to update a record lets say...
> >
> > I have a current value of 150 and the new value will be 250 now how
would I
> > total them to equal 400?
> >
> > I was thinking
> >
> > $sql = "UPDATE $table value1 =  value1 + ?
> >
> > is that correct?  how do you update it with simple math?
> >
> > What about division...
> >
> > take the current value in the database + the new value divided by
another
> > number, lets say another field



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Updating a record with math and division

2001-12-28 Thread Todd Williamsen

That isn't the answer I was looking for...

Since you are so nice could you be so kind in point me
where these golden docs are?  I looked all over php.net and mysql.com,
nada not only that the three books I have as well.  I am a newbie at
this, and do need a bit of hand holding thanks...


"Miles Thompson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
>
> Read the docs for the database in question. They will tell you what is and
is not allowed.
> Miles Thompson
>
> On Friday 28 December 2001 06:26 pm, Todd Williamsen wrote:
> > Ok
> >
> > So to update a record lets say...
> >
> > I have a current value of 150 and the new value will be 250 now how
would I
> > total them to equal 400?
> >
> > I was thinking
> >
> > $sql = "UPDATE $table value1 =  value1 + ?
> >
> > is that correct?  how do you update it with simple math?
> >
> > What about division...
> >
> > take the current value in the database + the new value divided by
another
> > number, lets say another field



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Updating a record with math and division

2001-12-28 Thread Miles Thompson


Read the docs for the database in question. They will tell you what is and is not 
allowed.
Miles Thompson

On Friday 28 December 2001 06:26 pm, Todd Williamsen wrote:
> Ok
>
> So to update a record lets say...
>
> I have a current value of 150 and the new value will be 250 now how would I
> total them to equal 400?
>
> I was thinking
>
> $sql = "UPDATE $table value1 =  value1 + ?
>
> is that correct?  how do you update it with simple math?
>
> What about division...
>
> take the current value in the database + the new value divided by another
> number, lets say another field

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]