UPATE Using Max?

2002-03-07 Thread Victoria Reznichenko

Rutledge,
Wednesday, March 06, 2002, 10:01:56 PM, you wrote:

Reoen In my application I would like to update a MySQL record where one
Reoen column
Reoen is the largest value.  Do I have to create a separate SELECT sql query
Reoen statement
Reoen to get that value and then update it?  Or, is there a function that
Reoen allows me to specify it as part of my WHERE clause.  I scanned the
Reoen manual and found reference to MAX, which appears to do it and can't get
Reoen it working.  
Reoen The syntax I've tried...
Reoen UPDATE PICKING SET COL_1 =3D 'My_VAL'  WHERE COL_2=3D'My_VAL2' AND
Reoen MAX(AUDIT);
^

It means that selection maximum value from table will be before
update.
This can be re-written as:

SELECT @a:=MAX(audit) FROM picking;
UPDATE picking SET col_1=  WHERE audit=@a;




-- 
For technical support contracts, goto https://order.mysql.com/
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___ ___   __
  /  |/  /_ __/ __/ __ \/ /Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
   ___/   www.mysql.com




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




UPATE Using Max?

2002-03-06 Thread Rutledge, Aaron

Hello,
In my application I would like to update a MySQL record where one
column
is the largest value.  Do I have to create a separate SELECT sql query
statement
to get that value and then update it?  Or, is there a function that
allows me to specify it as part of my WHERE clause.  I scanned the
manual and found reference to MAX, which appears to do it and can't get
it working.  
The syntax I've tried...
UPDATE PICKING SET COL_1 =3D 'My_VAL'  WHERE COL_2=3D'My_VAL2' AND
MAX(AUDIT);
and..
UPDATE PICKING SET COL_1 =3D 'My_VAL'  WHERE COL_2=3D'My_VAL2' AND AUDIT
=
=3D
MAX(AUDIT);

Does MAX only worke for SELECTS?

Thanks for any help to this obvious newbie question!  --Aaron

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php