我怎么在django中做mysql“LIKE”?

时间:2011-02-20 01:06:17

标签: mysql django

SELECT * from myapp_mymodel WHERE code LIKE“914%”;

1 个答案:

答案 0 :(得分:4)

我建议您阅读本手册,它会清楚地告诉您如何执行此操作:http://docs.djangoproject.com/en/dev/ref/models/querysets/#startswith

MyModel.objects.filter(code__startswith='914')