How to count there is no specific character in a string in mysql

I have a table with a row with data like '/2323/3235/4545/222/', how can I count the number / in each row using only mysql.

+5
source share
2 answers

A quick search came up with the following:

SELECT LENGTH('/2323/3235/4545/222/') - LENGTH(REPLACE('/2323/3235/4545/222/','/','')) ... etc;
+5
source

link

SELECT LENGTH('/2323/3235/4545/222/') - LENGTH(REPLACE('/2323/3235/4545/222/', '/', '')) AS `occurrences`
+3
source

All Articles