I have a simple table and need to output the data in a way that permissions relevant to the area appear in the same row.
user | page | permission
-------------------------------
Jon | books | read
Jon | books | delete
Jon | photos | read
Jon | photos | edit
Desired output in HTML (not a new table):
user | page | read | edit | delete
-----------------------------------------------
Jon | books | X | | X
Jon | photos | X | X |
Basically I need to output the data and combine all rows that have the same user and page into a single row, where permissions become columns. I can write two queries but it seems to be inefficient to run second query from each row.
I tried grouping but it does not output all the results pertinent to each user:
SELECT *
FROM t1
GROUP BY user, page
What am I missing?