SQL: select from table where it doesnt exist in other for a user -
i have 2 tables, test
, studenttest
these structures:
test
:
testid subject totalpoints schoolsubject 1 programming 100 informatics 2 webdesign 80 informatics ...
studenttest
:
studenttestid userid testid timestudied points date 1 1 1 60 60 2015-05-20 2 2 1 100 80 2015-05-20 2 2 2 95 75 2015-05-20 ...
now want make page user can fill in marks (in studenttest
), want show tests user doesn't have marks for. example if user 1 logged in should see test 2 because user 1 has no marks test. user 2 shouldn't see because has marks existing tests.
i don't know sql should like.
can me please?
you can use exists
operator:
select subject, schoolsubject test t not exists (select * studenttest st t.testid = st.testid -- , possibly limit single studentid )
Comments
Post a Comment