Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Posts
    408
    Thanks
    17
    Thanked 2 Times in 2 Posts

    A second, subordinate key?

    Is this possible: I have a table with a unique autofill field. Then there is a second numerical field to tie the info to entries in another table. This field will have multiple matching entries.

    Finally I have a third field that will be an integer between 1 - 20. I want this third field to only allow one of each number for all entries with the same number in column 2. (I hope that made sense!)

    Example:

    Code:
    ------------------------------
    key1 | id2 | 1 | other fields 
    ------------------------------
    key2 | id2 | 2 | other fields 
    ------------------------------
    key3 | id6 | 1 | other fields 
    ------------------------------
    key4 | id8 | 8 | other fields 
    ------------------------------
    
    I want this  to not be allowed, because there is already a 1 that matches id2:
    
    key1 | id2 | 1 | other fields

  • #2
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,963
    Thanks
    120
    Thanked 76 Times in 76 Posts
    create unique index on second and third column
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search


  •  

    Posting Permissions

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