By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
SELECT version();
version() |
---|
8.0.30 |
CREATE TABLE tablename (
a INT(10) NOT NULL,
b INT(10) NOT NULL,
UNIQUE ((LEAST(a, b)), (GREATEST(a, b)))
);
INSERT INTO tablename (`a`, `b`) VALUES ('1', '2');
INSERT INTO tablename (`a`, `b`) VALUES ('2', '1');
Duplicate entry '1-2' for key 'tablename.functional_index'