473,775 Members | 2,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get the highest result from a msql_query using php?

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
Dec 1 '07 #1
7 1223
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
Dec 1 '07 #2
On Dec 1, 10:43 am, "Shelly" <sheldonlg.n... @asap-consult.comwrot e:
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
Dec 1 '07 #3
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?
Dec 1 '07 #4
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.
Dec 1 '07 #5

"Jonas Werres" <jo***@example. orgwrote in message
news:47******** *************** @newsspool2.arc or-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.
Dec 1 '07 #6
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
Dec 2 '07 #7
Not to worry - the php is working out better for my design and I
almost have it sorted now anyway.
And I am almost sure, that even a second query would work out better.
Dec 2 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4163
by: andreas.muller | last post by:
Hello everyone, I'm trying to solve this problem but can't seem to figure out how to start. I would like to create a rating system where people can vote (1-5 stars) on randomly displayed items. The randomly displayed items should either have very high ratings OR a very low number of ratings. For example, only return items in the top 20th percentile *OR* items with fewer than 5 votes. The question is, how would I write an SQL query to...
2
2647
by: Dirtyweeker | last post by:
Hi, I have a database which records fitness test results of pupils. There are the usual name fields and then a series of fields holding results, e.g. field BP1 and field BP2; each of these fields holds a test result in numerical form. Let's assume BP1 value is 55 and BP2 value is 57. My problem is that I want to have a report which will only give me the highest result for that test for each pupil; I need to be able to extract the...
7
6305
by: NoKetch | last post by:
I have a simple program to output log2(x) but the result is not whole numbers. Here is the code: ---------------------- #include <stdio.h> #include <math.h> int main() { double x;
21
13479
by: Jaspreet | last post by:
I was working on some database application and had this small task of getting the second highes marks in a class. I was able to do that using subqueries. Just thinking what is a good way of getting second highest value in an integer array. One method I know of is to make the 1st pass through the array and find the highest number. In the second pass we can find the highest number which is less than the number we obtained in the 1st pass.
6
24337
by: Ada | last post by:
hello folks, is there a way to retrieve the highest value in the ArrayList? let say i have a value in the array: {1, 4, 15, 3, 7} it should return a value 15 as the result. i've looked at the Sort Method ( ) but doesn't seem like it can do the job or am i missing something?
4
4896
by: johnk | last post by:
I have a table of items, with revision numbers. I need to extract the items with highest revision number. The items may be listed several times and I don't know what the highest revision number for each item is. How do I do this?
17
7719
by: rhitz1218 | last post by:
Hi, I'm trying to create a function that will sort a number's digits from highest to lowest. For example 1000 - will become 0001 or 1234 to 4321
3
2001
by: jaimedp | last post by:
Hi, I have a table like the following: TableName = Table1 DX1, DX1_DESC, DRG The values from the 3 columns looks like the following
5
3792
by: ryuchi311 | last post by:
In C++ using arrays. I need to create a C Program that will ask for five integers input from the user, then store these in an array. Then I need to find the lowest and highest integers inside that array and add them together. The output will be the result in this format: LOWEST+HIGHEST=SUM #include<stdio.h> void main (){ int r, low, hig, ans, index; for(index=0, index<4, index++){ printf("Enter number");
0
10268
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10107
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10048
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9916
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8939
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6718
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2853
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.