Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何MyModel根据文本字段中某个短语的出现次数过滤我的模型MyModel
MyModel
我想这不能用 django orm 完成,也许 SQL 查询可以帮助?
就像是:
MyModal.objects.extra(count="SQL query that finds occurence count of a certain phrase in certain model field")
一个完整的原始查询也很好。
试试这个:
set @str='a b a c'; select length(@str)-length(replace(@str,'a','')) as 'number of occuarence'