By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE mytable
(
id int primary key auto_increment,
col1 varchar(30),
col2 varchar(30),
col3 varchar(30),
col4 varchar(30),
col5 varchar(30)
);
INSERT INTO mytable (col1, col2, col3, col4, col5)
SELECT 'val1' as val1, null as val2, null as val3, 'val4' as val4, null as val5
UNION ALL SELECT null, 'val2', null, null, null
UNION ALL SELECT 'val1', null, 'val3', null, 'val5';
INSERT INTO mytable (col1, col2, col3, col4, col5) VALUES
(null, 'val2', 'val3', 'val4', null),
('val1', null, 'val3', null, 'val5');
select * from mytable;
id | col1 | col2 | col3 | col4 | col5 |
---|---|---|---|---|---|
1 | val1 | null | null | val4 | null |
2 | null | val2 | null | null | null |
3 | val1 | null | val3 | null | val5 |
4 | null | val2 | val3 | val4 | null |
5 | val1 | null | val3 | null | val5 |