Reputation: 4071
I have a table with a row with the data like '/2323/3235/4545/222/'
how can i count the number of / in every row using mysql only.
Upvotes: 5
Views: 142
Reputation: 1042
SELECT LENGTH('/2323/3235/4545/222/') - LENGTH(REPLACE('/2323/3235/4545/222/', '/', '')) AS `occurrences`
Upvotes: 3
Reputation: 5136
A quick search came up with this:
SELECT LENGTH('/2323/3235/4545/222/') - LENGTH(REPLACE('/2323/3235/4545/222/','/','')) ... etc;
Upvotes: 5