Jump to content

Problem finding MAX


attaboy

Recommended Posts

You need to write this in clear english I think, because you're selecting from two tables and never join them. It's not clear what you're attempting to do.

It looks like you're trying to get the count of each country, and then get the maximum from that?

 

AFAIK, you cannot reference a new column name (like num) in your statement, would have to do MAX(COUNT(*)) not MAX(num). But the entire thing looks wrong.

 

Please explain what you're attempting to do, and figure out how to join your tables.

Link to comment
https://forums.phpfreaks.com/topic/261963-problem-finding-max/#findComment-1342384
Share on other sites

Thanks for the reply.  I'm pretty sure it's a legitimate join and the alias is a real alias because it works and this comes straight from joins section of a book published by MySQL Press.  I'm trying to get the country with the highest number of cities.

SELECT COUNT(*)AS num, country.Name
FROM country, city
WHERE CountryCode = Code
GROUP BY country.Name
HAVING num > 200;

post-98811-13482403475311_thumb.png

Link to comment
https://forums.phpfreaks.com/topic/261963-problem-finding-max/#findComment-1342397
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.