Reputation: 1
I'm looking to see if it's possible to only display results with multiple instances of a single character. For instance, if I wanted to only show rows that have the "," character in it more than 6 times.
Example: I, am, trying, to, figure, out, this, query
Would show in the results, but any row with less than 6 ","'s wouldn't show.
Upvotes: 0
Views: 336
Reputation: 32392
Here's a way using length
and replace
to show strings that have ,
6 or more times:
select * from mytable where length(mycolumn) - length(replace(mycolumn, ",", "")) >= 6
Upvotes: 1
Reputation: 1269443
One method uses like
:
select t.*
from t
where col like '%,%,%,%,%,%,%';
This should work in any database.
Upvotes: 0