I have two tables: Employees
and Pharmacies
.
In table Employees
I have a column name Pharmacy
which tells me what pharmacy an employee works at, and also a column with the names of the employees.
In table Pharmacies
I have a column of pharmacies and I want to add a new one named Number_of_employees
which to contain the number employees from the corresponding pharmacy where he works.
Any ideas how to do this ?
CodePudding user response:
DON'T ADD the column Number_of_employees
you can return Number_of_employees
value by query
Select Pharmacies.*, count(Employees.Pharmacy) as Number_of_employees from Pharmacies
join Employees on Pharmacies.id = Employees.Pharmacy
group by Employees.Pharmacy