Możesz to zrobić za pomocą NULL wartości. Jeśli używasz NULL zamiast „H ”, MySQL zignoruje wiersz podczas oceny UNIQUE ograniczenie
:
A UNIQUE index creates a constraint such that all values in the index must be
distinct. An error occurs if you try to add a new row with a key value that
matches an existing row. This constraint does not apply to NULL values except
for the BDB storage engine. For other engines, a UNIQUE index permits multiple
NULL values for columns that can contain NULL.
To trochę oszustwo i oznacza, że nie możesz mieć swoich danych dokładnie tak, jak chcesz. Więc to rozwiązanie może nie odpowiadać Twoim potrzebom. Ale jeśli możesz przerób swoje dane w ten sposób, powinno działać.