I have three tables
tbl_worker
City WorkerName Job
10 Raymond Carpenter
10 Sara Programmer
11 John Painter
11 Alice Booker
tbl_workshop
City WorkshopName
10 Dell
11 Apple
10 Sony
Tbl_city
Id Name
10 Mexico
11 Sydney
Now I want such a result:
City WorkersQty WorkshopQry
Mexico 2 2
Sydney 2 1
The result returns the quantity of workers and workshops which are registered in different cities.
what query should I write?
Group the
tbl_workshopandtbl_workertables individually, then use aLEFT JOINto get the results:If you want to only show the cities that have workshop’s or workers, add: