This is a discussion on Get the highest result from a msql_query using php? within the PHP Language forums, part of the PHP Programming Forums category; I have a result resource from a large mysql query and I need to find the single the highest value ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Ciaran wrote:
> I have a result resource from a large mysql query and I need to find > the single the highest value from a certain field. What's the best way > to pull it off? > Cheers, > Ciarán A simple google of "sql max" would have led you to: SELECT MAX(expression ) FROM tables WHERE predicates; -- Shelly |
|
|||
|
On Dec 1, 10:43 am, "Shelly" <sheldonlg.n...@asap-consult.com> wrote:
> Ciaran wrote: > > I have a result resource from a large mysql query and I need to find > > the single the highest value from a certain field. What's the best way > > to pull it off? > > Cheers, > > Ciarán > > A simple google of "sql max" would have led you to: > SELECT MAX(expression ) > FROM tables > WHERE predicates; > > -- > > Shelly Thanks Shelly but I'm not great with sql and my query is already huge. I don't think I'll be able to modify it to include the max as well as everything else. Not to worry - I'm going to split the results into a 3d array and then try to sort it with php. Thanks for the help |
|
|||
|
> Thanks Shelly but I'm not great with sql and my query is already huge.
> I don't think I'll be able to modify it to include the max as well as > everything else. Not to worry - I'm going to split the results into a > 3d array and then try to sort it with php. > Thanks for the help So, you go to the library, take all the books, reorganise them, search for the one you want to read and return the rest? |
|
|||
|
Jonas Werres wrote:
>> Thanks Shelly but I'm not great with sql and my query is already huge. >> I don't think I'll be able to modify it to include the max as well as >> everything else. Not to worry - I'm going to split the results into a >> 3d array and then try to sort it with php. >> Thanks for the help > > So, you go to the library, take all the books, reorganise them, search > for the one you want to read and return the rest? Nice comparison there. |
|
|||
|
"Jonas Werres" <jonas@example.org> wrote in message news:47519002$0$13116$9b4e6d93@newsspool2.arcor-online.net... >> Thanks Shelly but I'm not great with sql and my query is already huge. >> I don't think I'll be able to modify it to include the max as well as >> everything else. Not to worry - I'm going to split the results into a >> 3d array and then try to sort it with php. >> Thanks for the help > > So, you go to the library, take all the books, reorganise them, search for > the one you want to read and return the rest? No, you throw the rest away! ;) R. |
|
|||
|
Actually, I'm using all returned records further down my page - I just
want to pull the newest one to reference at the top. Not to worry - the php is working out better for my design and I almost have it sorted now anyway. Cheers, Ciarán |
|
|||
|
Greetings, Ciaran.
In reply to Your message dated Sunday, December 2, 2007, 06:10:34, > Actually, I'm using all returned records further down my page - I just > want to pull the newest one to reference at the top. > Not to worry - the php is working out better for my design and I > almost have it sorted now anyway. Why You aren't using SQL ORDER BY clause then? Using it properly You'll be always sure that Your newest entry is always on the top of query result. -- Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru> |