jjpetrucelli
Programmer
I want to follow a users progress. I want to find all of the tables where he is listed in the 'created_by' or 'updated_by' fields. To accurately analyze this data I will also need to know some key things about some of the tables. I am looking at something like this;
SELECT t.name, s.name, d.d_id, p.p_id, e.e_id, tsa.tsa_id
FROM table t, table xst, table s, table d, table p, table e, table tsa
WHERE t.t_id = xst.t_id (+)
AND s.s_id = xst.t_id (+)
AND d.d_id = t.id (+)
AND d.d_id = s.id (+)
AND p.p_id = t.id (+)
AND p.p_id = s.id (+)
AND e.e_id = t.id (+)
AND e.e_id = s.id
AND tsa.tsa_id = t.id (+)
AND tsa.tsa_id = s.id (+)
AND (t.created_by = 'UserNameHere'
OR t.updated_by = 'UserNameHere'
OR s.created_by = 'UserNameHere'
OR s.updated_by = 'UserNameHere'
OR d.created_by = 'UserNameHere'
OR d.updated_by = 'UserNameHere'
OR p.created_by = 'UserNameHere'
OR p.updated_by = 'UserNameHere'
OR e.created_by = 'UserNameHere'
OR e.updated_by = 'UserNameHere'
OR tsa.created_by = 'UserNameHere'
OR tsa.updated_by = 'UserNameHere')
in this query, the tables 't' and 's' have a many to many relationship though the 'xst' table. Then for the following tables 'd', 'p', 'e', and 'tsa' they are all associated with an id from both 't' and 's'. Im trying to use the outter joins to get all possible info, i.e. i will get returns on t.updated and also something more down the line as in tsa.created. I am obvoiusly confused as to how to accurately do this.
Also in every table that has an updated or created 'by' it also has a corresponding date i.e. update_date, created_date. I would want to order by date as well, is there an easier way to do this rather than stating 'order by' then listing all of the possible dates? I would rather have the results sorted purely on date no matter if its from updated or created from one table or another
SELECT t.name, s.name, d.d_id, p.p_id, e.e_id, tsa.tsa_id
FROM table t, table xst, table s, table d, table p, table e, table tsa
WHERE t.t_id = xst.t_id (+)
AND s.s_id = xst.t_id (+)
AND d.d_id = t.id (+)
AND d.d_id = s.id (+)
AND p.p_id = t.id (+)
AND p.p_id = s.id (+)
AND e.e_id = t.id (+)
AND e.e_id = s.id
AND tsa.tsa_id = t.id (+)
AND tsa.tsa_id = s.id (+)
AND (t.created_by = 'UserNameHere'
OR t.updated_by = 'UserNameHere'
OR s.created_by = 'UserNameHere'
OR s.updated_by = 'UserNameHere'
OR d.created_by = 'UserNameHere'
OR d.updated_by = 'UserNameHere'
OR p.created_by = 'UserNameHere'
OR p.updated_by = 'UserNameHere'
OR e.created_by = 'UserNameHere'
OR e.updated_by = 'UserNameHere'
OR tsa.created_by = 'UserNameHere'
OR tsa.updated_by = 'UserNameHere')
in this query, the tables 't' and 's' have a many to many relationship though the 'xst' table. Then for the following tables 'd', 'p', 'e', and 'tsa' they are all associated with an id from both 't' and 's'. Im trying to use the outter joins to get all possible info, i.e. i will get returns on t.updated and also something more down the line as in tsa.created. I am obvoiusly confused as to how to accurately do this.
Also in every table that has an updated or created 'by' it also has a corresponding date i.e. update_date, created_date. I would want to order by date as well, is there an easier way to do this rather than stating 'order by' then listing all of the possible dates? I would rather have the results sorted purely on date no matter if its from updated or created from one table or another