I am new to sql I am using myphpadmin for my database I am trying to Control the display of Column if the user login is Admin or Not. The column I am displaying is From Two different Tables which are TableA and Tableb. I did combine the two tables that has common value in column display all the columns that need to be display if the user who logged in is an Admin but I have no idea how to control the display if its user who logged in
I have three tables named;
TableA:
id Name Section Grade status
1a aika Section1 A Active
2s B Inactive
===========================================
TableB:
id PR_id Name Section
111 2s laika Section2
222 2s Bes Section3
Query used to display column all together
SELECT * FROM TableA WHERE Name != ''
UNION
SELECT TableA.id, TableB.Name, TableB.Section, TableA.Grade, TableA.status
FROM TableA
INNER JOIN TableB ON TableA.id = TableB.PR_id
Output is;
id Name Section Grade status
1a aika Section1 A Active
2s laika Section2 B Inactive
2s Bes Section3 B Inactive
Tableuser
id username usertype
1 aika admin
2 den user
3 lina user
if aika is the one who logged in because she is admin
all this column will display for Admin
id Name Section Grade status
1a aika Section1 A Active
2s laika Section2 B Inactive
2s Bes Section3 B Inactive
but if den/lina who who logged in because she is a user the column that will only be display for her is below she will not see the column Grade
id Name Section status
1a aika Section1 Active
2s laika Section2 Inactive
2s Bes Section3 Inactive
I am trying this query but its not working I would treally appreciate any advice or suggestion / help thank you very much
Select usertype from Tableuser Where usertype='Admin'( SELECT * FROM TableA
WHERE Name != ''
UNION
SELECT TableA.id, TableB.Name, TableB.Section, TableA.Grade, TableA.status
FROM TableA
INNER JOIN TableB ON TableA.id = TableB.PR_id