Jump to content

mysql help - left join


canadian_angel

Recommended Posts

I need to expand on the first query by counting the number of flights from the citys in

my airline database and so far have come up with the second query;

 

The tables in the database are flight, and city.

flight columns:number, origincityid,destinationcityid,departure,duration and stops

city columns:id and name

 

SELECT city.name, flight.origincityid FROM city

LEFT JOIN flight ON city.id=origincityid

 

 

SELECT city.name, COUNT(origincityid.id) AS numflight

->FROM city LEFT JOIN flight ON origincityid=origincityid.id

->city.name;

Link to comment
https://forums.phpfreaks.com/topic/208368-mysql-help-left-join/
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.