Say I have a table:
+------------------------+
| Employees |
+------+--------+--------+
| Dept | Name | Salary |
+------+--------+--------+
| 1 | John | 10000 |
| 1 | Mary | 50000 |
| 2 | Alfred | 30000 |
+------+--------+--------+
Now I create two views:
create view dept1_memberview as select Dept, Name from Employees where Dept=1;
create view dept2_memberview as select Dept, Name from Employees where Dept=2;
What I want to do is give access to each employee in the table (their usernames match their entry under the 'Name' column) to the view that corresponds to the department they're in. I know I could just do:
grant select on db.dept1_memberview to John, Mary;
grant select on db.dept2_memberview to Alfred;
But mostly out of curious, and for larger databases with hundreds of employees, I would like to know how I'd do that.
Thanks in advance!