django orm在两个带有子查询的列中
想象我有两张桌子。一个人列出了客户拥有的许可证,每个许可都有特定版本和类型。另一表具有有关许可证(例如名称,价格,持续时间)的一般共享信息,也列出了类型和版本。
我需要查询信息表中是否与给定客户拥有的许可有关的任何行。在纯SQL中,可以使用此子查询来完成:
从版本_details中选择 *(版本,type)在(选择版本,从许可中键入company_id ='6f65e5cc-cd1f-4888888888888888888888888888236-38295bae393aa''); <<<<<<<<<<<<<<< /code>
有没有办法使用Django Orm来完成此操作?我知道如何使用子查询,但我不知道如何使用两列在其中做一个。
Imagine I have two tables. One lists licenses customers have, each with a specific version and type. The other table has general shared info about the licenses (eg name, price, duration), also listed by type and version.
I need to query the information table for any rows pertaining to licenses a given customer has. In pure SQL, that can be accomplished with this subquery:
select * from version_details where (version, type) in (select version, type from licenses where company_id = '6f65e5cc-cd1f-4888-a236-38295bae393a');
Is there a way to accomplish this with Django ORM? I know how to use a subquery but I can't figure out how to do a wherein with two columns.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)