Hi there,

Been trying to learn MySQL JOINs but to no avail. Perhaps I threw myself onto a bit too deep waters.

I have two tables, `time` and `multitime`:

time:
Code MySQL:
  	id | date | jobID | staffID | start | finish | total
eg. 8040  	2010-02-04  	1652  	8  	2010-02-02 20:20:00  	2010-02-02 20:40:00  	1200

multitime:
Code MySQL:
id | taskID | jobID | start | finish | total | staffID
eg.  5742  	8040  	1652  	2010-02-04 03:00:00  	2010-02-04 03:10:00  	600  	8

I need to select total time for every jobID both in time and multitime tables.
I was using this piece of code:
PHP Code:
$sel mysql_query("select distinct jobID from `time` where staffID = '8' && (`start` > '".$_POST['dateIn']." 00:00:01' && `finish` < '".$_POST['dateOut']." 23:59:59')") or die (mysql_error());

while (
$row mysql_fetch_array($sel)) {

   
$sel2 mysql_query("select sum(total) AS totalhrs from `time` where `staffID` = '8' && `jobID` = '".$row['jobID']."' && (`start` > '".$_POST['dateIn']." 00:00:01' && `finish` < '".$_POST['dateOut']." 23:59:59')") or die (mysql_error());
   
$row2 mysql_fetch_array($sel2);
   
$mainhours $row2['totalhrs'];


   
$sel2 mysql_query("select sum(total) AS totalhrs from `multitime` where `staffID` = '8' && `jobID` = '".$row['jobID']."' && `start` > '".$_POST['dateIn']." 00:00:01' && `finish` < '".$_POST['dateOut']." 23:59:59'") or die (mysql_error());
   
$row2 mysql_fetch_array($sel2);
   
$subhours $row2['totalhrs']; 
which still didn't do its job, because if a task was stored only in `multitime` table (each time can have several multitimes), this was ommited, so the query didn't return true data.

I guess some sort of JOIN is required here, but I am completely stuck, cannot even make the query work, contanstly making syntax errors.

Can anyone help me out here or guide me?
Any help much much appreciated.

Thanks!
Cheers,
Greg