I'm doing a database about attractions in TN, here are my tables


I want to find the number of attractions and the cities name for any given city
And I want to list the name and attractions for a given city How would I go about doing that?
I tries this for the second one but it did not work
SELECT attractions.attraction_Name, Cities.city_Name FROM Cities INNER JOIN attractions WHERE city_ID=1
Any suggestions?
This is what I get

As i mentioned in my comment: You miss the on clause:
SELECT attractions.attraction_Name, Cities.city_Name
FROM Cities INNER JOIN attractions on cities_ID=city_ID WHERE city_ID=1
What you get is called cross product. Every entry of first table is joind with every entry from second table
The Count query can look like:
SELECT COUNT(*), Cities.city_Name
FROM Cities
INNER JOIN attractions ON attractions.city_ID = Cities.cities_ID
GROUP BY Cities.city_name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With