"Almost" unique constraints

  • Is there a way to allow only *one* multiple value in an otherwise-unique column? In other words, is there a provision to allow for "exceptions" to a unique constraint?

    For example, let's say I have a data column filled with the following rows:

    Table

    Chair

    Lamp

    I *do* want to allow multiple instances of "chair," so the following would be allowed:

    Table

    Chair

    Chair

    Lamp

    Chair

    However, I *do NOT* want to allow multiple values of anything else; therefore, trying to enter "table" or "lamp" would result in an error.

    On a related note: I defined a unique column in a database, and I set it to allow NULLs. However, it's giving me errors because of multiple instances of NULL. Would this be a limitation of the question I stated above, or should a unique column allow multiple NULLs?

    Thanks in advance for your help!

  • See duplicate thread.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply