Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2010
    Posts
    1

    Unanswered: Duplicate Values in mysql database

    Hi,

    I was wondering is it possible to ensure that their cant be duplicate fields on non primary fields? i can ensure that primary keys cant be duplicated but i was wondering can other fields be set so they cant be duplicated?

    okay so for example:

    i have a store table and a site table

    Store
    Store_id(PK)
    Store_site_id(FK)
    Router number(unique key cant be the same)

    Site
    site_id(pk)
    store_site

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by seanog2001 View Post
    I was wondering is it possible to ensure that their cant be duplicate fields on non primary fields?
    sure

    ALTER TABLE Store
    ADD UNIQUE ( Router )
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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