0

Simple question. Just wondering if this can be done without me having to enforce this constraint manually in my Java code. These two foreign keys (together in the same table) both refer out to another table, but for each row, they must not be allowed to point to the same foreign item.

link text

1 Answer 1

2

You can use a check contraint to enforce that two columns have different values:

ALTER TABLE TableName ADD CONSTRAINT ConstraintName CHECK fk1 <> fk2 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.