title: column 'barcode' in field list is ambiguous
body: <pre><code>SELECT barcode, t3.employee,
  SEC_TO_TIME(SUM(TIMESTAMPDIFF(SECOND, dateandtime, (SELECT IFNULL(MIN(dateandtime),NOW())
                                                    FROM wwtlog b
                                                   WHERE b.barcode = a.barcode
                                                     AND b.dateandtime  &gt; a.dateandtime
                                                     AND b.inorout = 'IN'
                                                  )))) timeused
  FROM wwtlog a
      JOIN (SELECT t1.barcode, t1.employee FROM wwtlog t1
    JOIN (SELECT barcode, MAX(id) id FROM wwtlog GROUP BY barcode) t2
  ON t1.id = t2.id AND t1.barcode = t2.barcode) t3 ON t1.barcode = barcode
  WHERE inorout = 'OUT' and barcode IN (SELECT t1.barcode FROM wwtlog t1
                                  JOIN (SELECT barcode, MAX(dateandtime) dateandtime FROM wwtlog GROUP BY barcode) t2
                                  ON t1.barcode = t2.barcode AND t1.dateandtime = t2.dateandtime WHERE inorout = 'IN')
  GROUP BY barcode;
  </code></pre>
  
  <p>Any help on this would be fantastic, I started getting this when I added the join in to get t3.employee. I have a feeling that I don't know what I'm doing.</p>
  
  <p>Im trying to get Unique Barcode, with the total time between time IN and time OUT time stamps. I was trying to use the join to get the employee that last had the item(barcode) checked out or in. if you take out the join for t3.employee, and just ask for employee, it gives me the first record employee for each barcode, not the last one.</p>