0

I have a table with rows that includes usernames. I have two users who will view the table and I want to filter the table to show specific usernames based on who the session_user is. Is this possible?

Sample Data

Username| 
---------
 1      |
 2      | 
 3      | 
 4      |
 5      |
 6      |

If session_user() = 'A', table should only show

Username| 
---
 1|
 2| 
 3|

If session_user() = 'B', table should only show

Username| 
---
 4|
 5| 
 6|

Additional condition: Aside from the 2 viewers, all usernames will be added as viewer but will be filtered as well only for their own data.

So basically, if the viewer is one of the usernames then it will only show their own data but if it is one of the managers, table will show usernames that's been assigned to them.

Zyre Soriano
  • 575
  • 4
  • 13
  • 25
  • Do you simply want something like `where session_user = usercolumn` – jarlh Feb 19 '20 at 15:19
  • Lets say I have rows 1,2,3,4,5,6. Then I have session_user A and B. When session_user = A then only rows 1,2,3 will show but when session_user = B, only rows 4,5,6 will show. I'm just not sure how I can do this in 'Where' clause. – Zyre Soriano Feb 19 '20 at 15:37
  • Edit the question and add some sample table data and the expected result. (As formatted text, not images.) – jarlh Feb 19 '20 at 15:39
  • I added samples – Zyre Soriano Feb 19 '20 at 16:55
  • 1
    I'd add a column user to the table, and store A for row 1, 2 and 3. etc. How else do you know which user the coming row with id 13 belongs to? – jarlh Feb 19 '20 at 20:18

0 Answers0