SELECT pq.id FROM printQueue pq JOIN report r ON r.id = pq.reportFk WHERE pq.statusCode = 'queued' AND r.method IS NOT NULL ORDER BY pq.priorityFk ASC LIMIT 1 FOR UPDATE