请教问题.
现在想查询 不在 fabric_name = 'default' 中的所有 user
这么写没毛病吧? 还有其他方式吗?
SELECT *
FROM django_info.auth_user
LEFT OUTER JOIN (
fd_users_groups_m2m AS fd_users_groups_m2m_1
INNER JOIN fd_group AS fd_group_1
ON fd_group_1.id = fd_users_groups_m2m_1.fd_group_id
where fd_group_1.fabric_name != 'default')
ON django_info.auth_user.id = fd_users_groups_m2m_1.fd_user_id
1
chaleaochexist OP ```
SELECT "posts_user"."id", "posts_user"."name" FROM "posts_user" WHERE NOT ( "posts_user"."id" IN ( SELECT U1."user_id" AS Col1 FROM "posts_user_group" U1 INNER JOIN "posts_group" U2 ON (U1."group_id" = U2."id") WHERE U2."title" = 1) ) ``` |
2
chaleaochexist OP 但是如何翻译成 sqlalchemy...
|
3
Hanayok 2019-01-14 18:57:58 +08:00
如果你的 m2m 字段写在 auth 表的话就这样
django_info.auth_user.objects.exclude(fd_group__fabric_name='default').all() |
4
xuanbg 2019-01-15 07:32:09 +08:00
|