• Sorry, I would like to help, but there are just too many things about all of this that don't make sense to me.

    For example, why are you (seemingly) storing students more than once in the STUDENT table?

    And shouldn't there be another table for SCHOOLS, with a single primary key (ID) that you would reference from other tables such as STUDENT, rather than having "schoolid" and "schoolkey" both stored in STUDENT?

    If you alter your design so it is properly normalized, you will eliminate redundant and incoherent data, and it will vastly simplify your queries.


    "If I had been drinking out of that toilet, I might have been killed." -Ace Ventura