开发者

Complex 'AND' Django Queries

开发者 https://www.devze.com 2023-03-23 14:19 出处:网络
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 somethi

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

精彩评论

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