1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
| --------------
SET AUTOCOMMIT = 0
--------------
--------------
START TRANSACTION
--------------
--------------
DROP DATABASE IF EXISTS `base`
--------------
--------------
CREATE DATABASE `base`
DEFAULT CHARACTER SET `latin1`
DEFAULT COLLATE `latin1_general_ci`
--------------
--------------
DROP TABLE IF EXISTS `test`
--------------
--------------
CREATE TABLE `test`
( `clef` integer unsigned NOT NULL primary key,
`col1` varchar(255) NOT NULL DEFAULT '',
`col2` varchar(255) NOT NULL DEFAULT '',
`col3` varchar(255) NOT NULL DEFAULT '',
`col4` varchar(255) NOT NULL DEFAULT '',
`col5` varchar(255) NOT NULL DEFAULT ''
) ENGINE=InnoDB
DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
insert INTO `test` (`clef`,`col1`,`col2`,`col3`,`col4`,`col5`) VALUES (1, '', 'c', 'e', '', 'h')
on duplicate key update col1 = case when values(col1) = '' then col1 else values(col1) end,
col2 = case when values(col2) = '' then col2 else values(col2) end,
col3 = case when values(col3) = '' then col3 else values(col3) end,
col4 = case when values(col4) = '' then col4 else values(col4) end,
col5 = case when values(col5) = '' then col5 else values(col5) end
--------------
--------------
insert INTO `test` (`clef`,`col1`,`col2`,`col3`,`col4`,`col5`) VALUES (1, 'a', 'd', '', 'g', '')
on duplicate key update col1 = case when values(col1) = '' then col1 else values(col1) end,
col2 = case when values(col2) = '' then col2 else values(col2) end,
col3 = case when values(col3) = '' then col3 else values(col3) end,
col4 = case when values(col4) = '' then col4 else values(col4) end,
col5 = case when values(col5) = '' then col5 else values(col5) end
--------------
--------------
insert INTO `test` (`clef`,`col1`,`col2`,`col3`,`col4`,`col5`) VALUES (1, 'b', '', 'f', '', 'i')
on duplicate key update col1 = case when values(col1) = '' then col1 else values(col1) end,
col2 = case when values(col2) = '' then col2 else values(col2) end,
col3 = case when values(col3) = '' then col3 else values(col3) end,
col4 = case when values(col4) = '' then col4 else values(col4) end,
col5 = case when values(col5) = '' then col5 else values(col5) end
--------------
--------------
insert INTO `test` (`clef`,`col1`,`col2`,`col3`,`col4`,`col5`) VALUES (2, 'j', '', '', 'm', 'n')
on duplicate key update col1 = case when values(col1) = '' then col1 else values(col1) end,
col2 = case when values(col2) = '' then col2 else values(col2) end,
col3 = case when values(col3) = '' then col3 else values(col3) end,
col4 = case when values(col4) = '' then col4 else values(col4) end,
col5 = case when values(col5) = '' then col5 else values(col5) end
--------------
--------------
insert INTO `test` (`clef`,`col1`,`col2`,`col3`,`col4`,`col5`) VALUES (2, '', '', 'l', '', '')
on duplicate key update col1 = case when values(col1) = '' then col1 else values(col1) end,
col2 = case when values(col2) = '' then col2 else values(col2) end,
col3 = case when values(col3) = '' then col3 else values(col3) end,
col4 = case when values(col4) = '' then col4 else values(col4) end,
col5 = case when values(col5) = '' then col5 else values(col5) end
--------------
--------------
insert INTO `test` (`clef`,`col1`,`col2`,`col3`,`col4`,`col5`) VALUES (2, '', 'k', '', '', 'o')
on duplicate key update col1 = case when values(col1) = '' then col1 else values(col1) end,
col2 = case when values(col2) = '' then col2 else values(col2) end,
col3 = case when values(col3) = '' then col3 else values(col3) end,
col4 = case when values(col4) = '' then col4 else values(col4) end,
col5 = case when values(col5) = '' then col5 else values(col5) end
--------------
--------------
select * from `test`
--------------
+------+------+------+------+------+------+
| clef | col1 | col2 | col3 | col4 | col5 |
+------+------+------+------+------+------+
| 1 | b | d | f | g | i |
| 2 | j | k | l | m | o |
+------+------+------+------+------+------+
--------------
COMMIT
--------------
--------------
SET AUTOCOMMIT = 1
--------------
Appuyez sur une touche pour continuer... |
Partager