used sql queries for matching semesters