1) "IF NEW.MENTOR = .STDNO" is invalid. That line should read:
IF :NEW.MENTOR = stdno
2) S.COURSECODE is meaningless outside of the SELECT statement above it.
3) Table alias must come after table name not before ("STUDENT S" not "S STUDENT")
4) :NEW and :OLD can only be used in a FOR EACH ROW trigger, which this is not. And FOR EACH ROW triggers cannot select from the table they are based on, or you will get the "mutating table" error.
5) You do not deal with the case where the mentor's record is updated.
6) You do not handle INSERTs.
I think your trigger needs to be more like this:
CREATE OR REPLACE TRIGGER nevermentor
AFTER INSERT OR UPDATE OF STUDENT
( SELECT NULL
FROM STUDENT S, STUDENT M
WHERE M.STDNO = S.MENTOR
AND S.COURSECODE = M.COURSECODE
AND ROWNUM = 1
IF v_count > 0 THEN
raise_application_error(-20012, 'Mentor and his/her student cannot enrol in the same course');
This looks for any student/mentor pairs that attend the same course after the update/insert.
Since this question is Oracle-specific I will move it to the appropriate forum.
SQL = Structured Query Language. This is common to many DBMSs: Oracle, Microsoft SQL Server, IBM DB2, mySQL, ... (though there are always some differences). It includes SELECT, INSERT, UPDATE, DELETE statements.