1主题:关于鸟类的电子邮件 电子邮件 2 题:鸟电子邮件 3 4 标记 个人5 lex 个人6 主题:蚂蚁 电子邮件
我将数据存储在两个名为objects和object_relationships的表中。这是一个简单的自我指代多对多。
对象表
描述从object
表中获取一个ids
的数组,并按该数组的元素搜索object_relationships
中的行。
select object_id, type, child_id
from (
select array_agg(id) as ids
from objects
where description like any('{%birds%, %lex%, %john%}')
) s
join object_relationships
on object_id = any(ids) and child_id = any(ids)
order by object_id, child_id;
在db<gt;不停摆弄