RE: [PHP] getting the highest number in 3 db fields?

From: Date: Fri, 19 Nov 2004 16:00:41 +0000
Subject: RE: [PHP] getting the highest number in 3 db fields?
Groups: php.general 
Request: Send a blank email to php-general+get-202522@lists.php.net to get a copy of this message
If we're trying to get the max value between 3 columns in a row like this: Prolog transmodal asian 1 2 3 We'd want to get the value "3" If you wanted to get the max out of three values in a row, you might do something like this: SELECT MAX(prolog, transmodal, asian) FROM sometable I think that'd work. But then there's mention of row1 vs row2 vs row3.. So I guess I'm confused. In which case, if we're looking at: Name Value ---- ----- Prolog 1 Transmodal 2 Asian 3 Then you'd do something like this: SELECT Name, Max(Value) FROM sometable group by Name You can do this in PHP as well, but make the DB server do all the work. :) -TG > -----Original Message----- > From: Dennis Seavers [mailto:deseavers@mindspring.com] > Sent: Friday, November 19, 2004 1:46 AM > To: Louie Miranda > Cc: php-general@lists.php.net > Subject: RE: [PHP] getting the highest number in 3 db fields? > > > Try using the SQL aggregate function MAX() or the PHP function max() > > > > [Original Message] > > From: Louie Miranda <lmiranda@gmail.com> > > To: <php-general@lists.php.net> > > Date: 11/18/2004 11:34:57 PM > > Subject: [PHP] getting the highest number in 3 db fields? > > > > I have a db field of 3. > > > > - prolog > > - transmodal > > - asian > > > > I wish to get the highest number of those three, in > different fields. > > > > Im thingking of.. > > > > if (row0 =< row1) ... > > > > how about row2? > > > > confused.. > > > > -- > > Louie Miranda > > http://www.axishift.com

« previous php.general (#202522) next »