2 ms·
Whoa I was way overcomplicating this. This is all you need, semantics AND ergonomics included: CREATE TABLE P ( name VARCHAR(100), count INT NU
by infogulch 10y ago
Whoa I was way overcomplicating this. This is all you need, semantics AND ergonomics included:
CREATE TABLE P (
name VARCHAR(100),
count INT NULL,
count_empty AS CASE WHEN count IS NULL THEN 1 ELSE 0 END,
count_key AS ISNULL(count,0),
PRIMARY KEY (name, count_empty, count_key)
);
No trigger or updating two fields needed at all. Just update "count". If you insert NULL twice it will yell at you.