Results 1 to 2 of 2

Thread: Insert If

  1. #1
    Join Date
    Feb 2002
    Location
    New Jersey
    Posts
    39

    Unanswered: Insert If

    I have, lets say two tables, one Course, and the other Student.

    Table: Course
    Attributes: CourseID
    StudentID

    Table: Student
    Attributes: StudentID
    Name

    How do I prevent the student from being able to register for more than 10 classes?

  2. #2
    Join Date
    Mar 2001
    Location
    Lexington, KY
    Posts
    606
    You would have to perform a query in your application beforehand since MySQL does not support constraints.

    e.g.
    Code:
    LOCK TABLE course
    SELECT COUNT( * )
      FROM course
     WHERE studentid = $someid
    
    IF count > 9
      echo "no!"
    ELSE
      INSERT
    UNLOCK TABLE course
    Thanks,

    Matt

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •