Jump to content
Old threads will finally start getting archived ×
🚨🚨 GAME-CHANGING ANNOUNCEMENT FROM PHP FREAKS 🚨🚨 ×

2 Field Max


Copilot 🤖

Recommended Posts

I have a table of years and numbers that refer to seasons in another table.

 

It looks something like this:

yr number

2002 2

2003 1

 

I need to create a query that selects the latest yrnumber COMBO. In this case, it would be 2003, 1.

 

Here is what I have tried:

 

SELECT MAX(yr), MAX(number) FROM issue

returned 2003, 2

 

SELECT MAX(yr), MAX(number) FROM issue WHERE yr=MAX(yr)

 

SELECT yr, number FROM issue WHERE yr=MAX(yr) AND number=MAX(number)

 

Both returned error \"Invalid use of group function\"

 

Any other ideas? I know mysql does not support sub-queries, so do I have to use two?

 

Sorry to bug you on a seemingly trivial issue, but I TRY to always learn how to do things the in the best and most efficient manner.

Link to comment
https://forums.phpfreaks.com/topic/48-2-field-max/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.