Hello,
I posted this on the PHP forum but I was told I would have better success here.
I need to write a query that produces multi-layered results.
For example I have moderators who moderate groups of users, the group names, the user's names who belong in the groups and then some data on each of those users I need it to return in a format that groups the data under the user, the user under the group and the group under the moderator in the following format:
I have three database tables, one of which (users) needs to be queried twice.Moderator: Randy
Group: Group 1
Name 1
data
data data
Name 2
data
data data
Group 2
Name 1
data
data data
data data data
Moderator: Joe
Group: Group 1
Name 1
data
data data
Name 2
data
data data
First query: select id, fname, lname from users where permissions = 'mod'
Table: users
columns: id, fname, lname
Second query: select id, group_name from groups where mod='"result from first query"'
Table: groups
Columns: id, group_name
Third query: select id, fname, lname from users where group='result from second query'
table: users (second pass)
columns: id, fname, lname
Final query: select text_data from data where user_id ='Result from third query'.
Table: data
columns: text_data
Thank you in advance for any help rendered.







Bookmarks