#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2005
    Posts
    641
    Rep Power
    25

    Creating non-standard foreign key


    I have two tables, Table 1 and Table 2.

    I want to create a link between them, 1:n.

    The problem is that I want to create a foreign key on Table 2 where:

    Table2.Field1 = 1 (some static value)
    Table2.Field2 = Table1.Field1 (PK)

    Is this possible and if so, how would I do it?
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,203
    Rep Power
    4279
    yes, it's possible

    go about it exactly the same way you've created other FKs in the past
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo