Calculate occurences of phrase in Text Field Django
How can I filter my model MyModel on the basis of the number of occurences of a certain phrase in a text field in MyModel
I guess it can't be done with django orm, perhaps an SQL query can help?
MyModal.objects.extra(count="SQL query that finds occurence count of a certain phrase in certain model field")
A complete raw query is fine too.
set @str='a b a c'; select length(@str)-length(replace(@str,'a','')) as 'number of occuarence'