【发布时间】:2021-01-22 10:56:57
【问题描述】:
items
id | name | group
-----------------------------------------------------------
1 | /foo/ | app1
2 | /foo/1 | app1
3 | /bar/2 | app1
4 | /foo/abc/def | app1
5 | /foo3/ | app2
6 | /bar3/ | app2
mapping
id_a | id_b
--------------
1 | 2
3 | 4
mapping.id_a and mapping.id_b have foreign key references to item.id
我需要使用 gino sqlalchemy 查找给定输入“名称”和“组”的映射表中 id_a 和 id_b 之间是否存在关联。
例子:
- 对于输入 '/foo/', '/foo/1', 'app1' --> 匹配成功。
- 对于输入 '/bar/2', '/foo/abc/def', 'app1' --> 匹配成功。
- 对于输入 '/foo3/'、'/bar3/'、'app2' --> 匹配失败。
【问题讨论】:
-
什么是等效的高效的plsql查询。是通过嵌套查询还是连接?
标签: sql postgresql sqlalchemy gino