You can use either NOT IN or not exists to exclude subjects for which event='test' exists. Using order Limit 1 with order by id will select one row with lowest value of id column.
Schema and insert statements:
create table t1 (id int,subject varchar(20), day varchar(20), event varchar(20));
insert into t1 values(211, 'maths' ,'mon', 'asmnt');
insert into t1 values(222, 'maths' ,'tue', 'asmnt');
insert into t1 values(223, 'science' ,'mon', 'test');
insert into t1 values(224, 'science' ,'tue', 'asmt');
insert into t1 values(225, 'science' ,'wed', 'insp');
insert into t1 values(226, 'computers' ,'mon', 'asmt');
insert into t1 values(227, 'maths' ,'mon', 'test');
insert into t1 values(228, 'computers' ,'mon', 'insp');
insert into t1 values(229, 'computers' ,'thr', 'asmnt');
insert into t1 values(230, 'computers' ,'fri', 'asmnt');
Query1: using NOT IN
SELECT * FROM t1 a
WHERE subject not in
(
SELECT subject FROM t1 b WHERE b.event='test'
)
order by id
Limit 1
Output:
| id |
subject |
day |
event |
| 226 |
computers |
mon |
asmt |
Query2: using not exists
SELECT * FROM t1 a
WHERE not exists
(
SELECT 1 FROM t1 b WHERE b.event='test' and a.subject=b.subject
)
order by id
Limit 1
Output:
| id |
subject |
day |
event |
| 226 |
computers |
mon |
asmt |
db<>fiddle here