By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE tb_kse(id_no INT, ss_no INT, gen_col INT GENERATED ALWAYS AS (ifnull(ss_no, id_no)) STORED )
create index IDX_KSE_NO_01 on tb_kse(ifnull(ss_no, id_no));
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ss_no, id_no))' at line 1
create index IDX_KSE_NO_01 on tb_kse(gen_col);
Records: 0 Duplicates: 0 Warnings: 0
explain
SELECT *
FROM tb_kse
WHERE gen_col = 10;
id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | SIMPLE | tb_kse | null | ref | IDX_KSE_NO_01 | IDX_KSE_NO_01 | 5 | const | 1 | 100.00 | null |