SELECT pstampJob.*
FROM pstampJob
    JOIN pstampRequest USING(req_id)
    LEFT JOIN pstampDependent USING(dep_id)
WHERE pstampRequest.state = 'run'
    AND pstampRequest.fault = 0
    AND pstampJob.state = 'run'
    AND pstampJob.fault = 0
    AND (dep_id = 0 OR pstampDependent.state = 'full')
