So I have a table named files with the following values
File Name | End User Name
file1 | CNS
file2 | CNS
file3 | CNS
file4 | EndUser2
As you can see, the end user name is same. So what I want to do is basically display the end user name once and add a button that shows the list of all the files containing the end user name “CNS”. I want “CNS” to display once only, being a column of “files” table.
End User Name | Files
CNS | View Files
EndUser2 | View Files
I’m confused about what query will I use to display the same end user names only once.
Advertisement
Answer
As every entry in that table is accessing files, you don’t need to fetch anything with file
and you don’t need to group anything:
SELECT DISTINCT user, 'View Files' FROM tbl;