The best way is to set the values as unique:
CREATE TABLE subject_registerd (
no int primary key,
user_id int,
subject_code varchar(50),
UNIQUE (user_id, subject_code)
);
That would make it impossible to register the same combination of user_id and usbject_code twice.
But I don't understand your design of the database. You should use the primary keys in the other tables to do the relationship. Like this:
CREATE TABLE subject_registerd (
no int primary key, // Note that you don't need the no in this table, you can use no_student and no_subject as a primary key. But it is up you you how you handle it.
no_student int,
no_subject int,
UNIQUE (user_id, subject_code),
FOREIGN KEY no_student REFERENCES student(no),
FOREIGN KEY no_subject REFERENCES subject(no)
);
If you don't do it this way it is possible to change the subject code in the subject table without changing the relationships, and it will mess up your database.