View Single Post
Old Feb 18, 2005 | 07:39 AM
  #1  
Andreas's Avatar
Andreas
PassionFord Post Whore!!
 
Joined: May 2003
Posts: 3,551
Likes: 0
Default 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?
Reply