Hi all,

I posted my question a short time ago and didn't receive any answers. So I am trying describe it better.

I want to select For every user (from table t_user), every project (from t_project) and from every project I want to select every subproject which has the id of the project (t_subproject.subproject_id). That works so far.

my query :
----------

SELECT u.login, p.name, sp.name
FROM t_user u
LEFT JOIN t_project p ON 1
LEFT JOIN t_subproject sp ON p.id = sp.project_id

that gives out something like this:
+-------+-------------------------------+---------------------------+
| login | name                          | name                      |
+-------+-------------------------------+---------------------------+
| amg   | Railcalc                      | calculation               |
| amg   | Bogie Tools                   | Support                   |
| amg   | Bogie Tools                   | Andi                      |
| amg   | Bogie Tools                   | Bremsweg                  |
| amg   | Klima Tools                   | HVAC I                    |
| amg   | Klima Tools                   | HVAC II                   |
| amg   | Klima Tools                   | Silent Fan                |
| amg   | CoC Support                   | Ascalp                    |
| amg   | CoC Support                   | Fahrtemp                  |
| amg   | CoC Support                   | Support                   |

[...]

In this example Railcalc has only one subproject,the Bogie Tools-project has 3 subprojects and so on.

Now I've got a table t_time which has following rows:

minutes (INT)
owner (which is the same as the login eg.: amg)
subproject_id (which is the same as the id in the table t_subproject)

If there are entries which are:

60  / amg / 5
120 / amg / 5

(in this example '5' is the id of the calculation-subproject)

Then the result should be:

+-------+-------------------------------+---------------+-----------+
| login | name                          | name          | minutes   |
+-------+-------------------------------+---------------+-----------+
| amg   | Railcalc                      | calculation   | 180       |


That means I need the SUM of the minutes which belong to a subproject and a certain user.


Could anyone PLEASE help me?

   Thanks
      Sorin


--------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Reply via email to