ALTER TABLE submission_timedetails ADD COLUMN has_duplicate TINYINT(1) DEFAULT 0;

UPDATE  submission_timedetails all_details
	JOIN submissions all_submission
		ON all_submission.id = all_details.submission_id
	JOIN submission_timedetails dupe_details
		ON dupe_details.id != all_details.id
		AND dupe_details.start_time = all_details.start_time
		AND dupe_details.end_time = all_details.end_time
		AND dupe_details.from_suburb = all_details.from_suburb
		AND dupe_details.to_suburb = all_details.to_suburb
		AND dupe_details.transport_type = all_details.transport_type
	JOIN submissions dupe_submission
		ON dupe_submission.id = dupe_details.submission_id
SET all_details.has_duplicate =  1
WHERE
	all_submission.service_number = dupe_submission.service_number
	AND all_submission.weekend_sunday = dupe_submission.weekend_sunday;
