Selecting MAX from multiple fields

admin

Administrator
Staff member
Hi there, I hope the subject isn't too misleading but it's late and my brain is non-functioning.

I've been playing around with this for a while and need some help.

There are two tables: Authors and Articles.

I am trying to select the highest article number (ar_id) from the Articles table depending on the Author id (a_id) in the Authors table.

So right now there are two authors in there, I want to only display the highest article id for each author. Any ideas?? I'm using mySQL and PHP.

I've been playing around with different variations of:

SELECT max(ar_id) FROM Articles, Authors WHERE Authors.a_id = Articles.ar_author

... but for some reason it just keeps displaying the max article, ignoring the authors.

Sorry for so long winded! Thanks.
 
Back
Top