Comment compter le nombre d’occurrence d'un caractère dans une colonne ?
SET @string = "Bonjour ""Mr Vinal""; il fait beau l'été, l'automne et l'hivers, n'est ce pas ?";
SELECT
SUM( LENGTH(@string ) ) AS total_length,
SUM( LENGTH(@string) - LENGTH(replace(@string, ',', '')) ) AS coma_virgule,
SUM( LENGTH(@string) - LENGTH(replace(@string, '''', '')) ) AS quote_cote,
SUM( LENGTH(@string) - LENGTH(replace(@string, '"', '')) ) AS double_quote_cote,
SUM( LENGTH(@string) - LENGTH(replace(@string, ';', '')) ) AS semicolon_point_virgule
;
/*
+--------------+--------------+------------+-------------------+-------------------------+
| total_length | coma_virgule | quote_cote | double_quote_cote | semicolon_point_virgule |
+--------------+--------------+------------+-------------------+-------------------------+
| 79 | 2 | 4 | 2 | 1 |
+--------------+--------------+------------+-------------------+-------------------------+
*/