Well, imagine you have 3 tables (legacy system, cant be changed) and you need to get a list that has all the cities and the sales on each city for a specific employe id. The sales table will not have a record for a city if the employe had never made a sell there.
With some joins I can get the relevant data, but not the complete list with all the cities. I have this working putting the results of a SELECT * FROM city in a list and then running the SQL wuth joins to fill the sales column:
SELECT city.id, city.name, sales.sales, employe.id
FROM city
LEFT JOIN sales ON city.id = sales.cityFK
LEFT JOIN employe ON sales.employeFK = employe.id
WHERE employe.id = 10
What will be the best practice to get the “Desired Result” table directly with SQL?
Thanks