开发者

Complex 'AND' Django Queries

I'm trying to do the equ开发者_开发百科ivalent of this SQL query:

"SELECT * FROM something WHERE ((something >= something AND something <= something) AND(something >= something AND something <= something))"

And I can't quite figure it out. I've tried the following with no success..

.filter(( Q(something__gte=something) & Q(something__lte=something)) & ( Q(something__gte=something) & Q(something__lte=something)))

.filter( Q(something__gte=something,something__lte=something) & Q(something__gte=something,something__lte=something))

both returns the following.. and completely ignores my brackets...

WHERE (`something`.`something` >= something  AND `something`.`something` <= -something  AND `something`.`something` >= something  AND `something`.`something` <= something )


the logical operator AND is associative. a & b & c == (a & b) & c == a & (b & c). No parentheses are needed

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜