Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.