CREATE TEMPORARY TABLE tmp (Id int);
INSERT INTO tmp SELECT Candidate.Id
FROM
	Candidate
	INNER JOIN Campaign
	  ON Candidate.CampaignId = Campaign.Id
	INNER JOIN Course
	  ON Campaign.CourseId = Course.Id
WHERE
	Course.SegmentId IN (1, 6) AND
	Candidate.status NOT IN ('cancelled', 'pending_reenrollment', 'dropped', 'enrolled');

UPDATE Candidate
SET status = 'present'
WHERE Id IN (SELECT Id FROM tmp);
