I am attempting to create a constraint to enforce each row to have at least two of the four fields equivalent to each other.
I came up with
CHECK(
(CASE WHEN (CAMPO1=CAMPO2)
OR (CAMPO1=CAMPO3)
OR (CAMPO1=CAMPO4)
OR (CAMPO2=CAMPO3)
OR (CAMPO2=CAMPO4)
OR (CAMPO3 = CAMPO4)
THEN 1 END) = 1 );
However, to my surprise, the following INSERT statement went through.
INSERT INTO Ejercicio2A_2(
CAMPO1,
CAMPO2,
CAMPO3,
CAMPO4)
VALUES('A','B','C','D')
None of the values are equal to the other so I needed the constraint to reject the INSERT statement. Why did it not?