You would just get the amount of rows returned from this example query:
SELECT COUNT(*) FROM enrollment WHERE student_id = 'XYZ' AND subject = 'ABC' AND academic_period = 'DEF'
If the amount of rows returned is greater than 0, they have already been enrolled in that subject in the academic period.