1

I have a Mysql table with columns A (DateTime) and B (Int32). I want to create an index on this table that prevents duplicate values in A and B such that the following statement would fail: sql Insert Into Table(A, B) Values (null, 2); Insert Into Table(A, B) Values (null, 2);#should fail do to duplicate values I have created a unique index on columns A and B but it doesn't work for null values. Is there any way to reject this case?

  • 2
    if null should be stopped from being a duplicate, then there's no point having a null value. Just use zero or some other value instead. – Martin Aug 24 '17 at 14:07
  • 1
    null is not a value, it's a `null` – Martin Aug 24 '17 at 14:07
  • Duplicate of https://stackoverflow.com/questions/3712222/does-mysql-ignore-null-values-on-unique-constraints – gview Aug 24 '17 at 14:17
  • Possible duplicate of [Does MySQL ignore null values on unique constraints?](https://stackoverflow.com/questions/3712222/does-mysql-ignore-null-values-on-unique-constraints) – gview Aug 24 '17 at 14:17

0 Answers0