Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2005
    Posts
    67

    Unanswered: Unique index acrosss 2 tables

    Hi all,

    I have two tables: Users and companies. Both have field EMAIL as unique

    Is there any way to prevent duplicated email acrosss different tables?
    The idea is to prevent a company and a user with same email address.

    Currently I check it at moment of register wether the email exists on both tables, but I'd like to have something more solid.

    I'm using MySQL 5, MyISAM

    Thanks in advance

  2. #2
    Join Date
    Oct 2003
    Posts
    60
    You can't do that.

    why not redesign your db and have a table to hold unique email addresses and created FK's from the other 2 tables.

  3. #3
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Quote Originally Posted by scottb View Post
    created FK's from the other 2 tables.
    Not with MyISAM

  4. #4
    Join Date
    Oct 2003
    Posts
    60

    Red face

    Quote Originally Posted by shammat View Post
    Not with MyISAM
    oooooopsie.

  5. #5
    Join Date
    Feb 2010
    Location
    Montreal, CA
    Posts
    32
    Using 1 table instead of 2, you can solve your problem:

    TableA
    -------
    1- Email (PK)
    2- Type: User/Company
    3- ...

Tags for this Thread

Posting Permissions

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