Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Quick SQL question

Options
  • 17-04-2010 8:08pm
    #1
    Registered Users Posts: 427 ✭✭


    Hi,
    I am getting an error when creating a table of mine due to a foreign key in a MYSQL database.

    e.g.
    Tables:
    A
    idA PK

    B
    idB
    FK references A (idB->idA)

    C
    idC
    FK reference A (idC->idA)

    Is there some problem with this? I seem to be able to make one table referencing A with a foreign key but I cannot make two(Error 121).

    Thanks.


Comments

  • Closed Accounts Posts: 3,357 ✭✭✭Beano


    what error are you getting?


  • Moderators, Politics Moderators Posts: 39,853 Mod ✭✭✭✭Seth Brundle


    Double check dataypes on common fields.
    Is the table containing the PK created before the FK table?
    stick up your code!


  • Registered Users Posts: 427 ✭✭Kevo


    Ok so I explained that rather poorly. I oversimplified the problem. I just wanted to know was I making a very obvious error. If not it must be syntax.


    I will post code in a few mins.


    EDIT:
    Fixed my problem. All my FKs had the same name. I thought this would be ok since they are in different tables but I guess that since they reference the same table it becomes a problem.


  • Moderators, Politics Moderators Posts: 39,853 Mod ✭✭✭✭Seth Brundle


    Cool.
    FYI any structural item within a DB schema can be regarded as an object and gets a unique name.


Advertisement