in reply to SQL question: Insertion with FK constraint

Don't use that SQL syntax with REFERENCES right after the column definition. You need to define your foreign keys at the end of the table definition after all columns are declared or else MySQL will ignore it.
  • Comment on Re: SQL question: Insertion with FK constraint

Replies are listed 'Best First'.
Re^2: SQL question: Insertion with FK constraint
by dragonchild (Archbishop) on Jun 26, 2008 at 15:57 UTC
    This is completely incorrect for any version of MySQL 4+. 3.23 had this problem. It's been fixed.

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
      From the docs for 5.0:
      The inline REFERENCES specifications where the references are defined as part of the column specification are silently ignored by InnoDB. InnoDB only accepts REFERENCES clauses when specified as part of a separate FOREIGN KEY specification.
        Bah. I've done this before and it worked.

        My criteria for good software:
        1. Does it work?
        2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?