SQL help needed.
Im supposed to create a database in a uni assignment and need some hints on how to solve a problem.
Ive created 4 tables and one of them is a connection table for the others where i would like to run some test on the data entered to make shure it already exists in the database. You are supposed to sign up for a class by entering its ClassCode and the database should check if the ClassCode exists. ie the return a TRUE or FALSE to the database handler.
So basicily this is what i want to do:
CREATE TABLE ClassSignup
classcode VARCHAR(6) NOT NULL
CONSTRICTION CheckIfClasscodeExists
CHECK (EXISTS (SELECT classcode FROM class));
The problem is that the CHECK-statement dont allow me run subqueries within it so im stuck and dont know how to proceed to get the proper result?
Ive created 4 tables and one of them is a connection table for the others where i would like to run some test on the data entered to make shure it already exists in the database. You are supposed to sign up for a class by entering its ClassCode and the database should check if the ClassCode exists. ie the return a TRUE or FALSE to the database handler.
So basicily this is what i want to do:
CREATE TABLE ClassSignup
classcode VARCHAR(6) NOT NULL
CONSTRICTION CheckIfClasscodeExists
CHECK (EXISTS (SELECT classcode FROM class));
The problem is that the CHECK-statement dont allow me run subqueries within it so im stuck and dont know how to proceed to get the proper result?
Thread
Thread Starter
Forum
Replies
Last Post
Jim Galbally
General Car Related Discussion.
3
Sep 10, 2004 02:42 PM



