我有2个实体,比如entity [x]和[y]。两个实体都与一些标签相关联。实体[y]用于搜索相似的[x]实体。例如。如果实体[y]由标签“books”和“blogs”组成,我想要一个包含这两个标签的所有[x]实体的列表。获取匹配相同标记的实体列表sql
我的表架构是:
[x]
entity_id int // its a foreign key from entity table
tag varchar // this is the tag to be matched
(one entity can have multiple tags hence multiple rows of same entity
id will be inserted)
[y]
entity_id int // again a foreign key from entity2 table
tag varchar // tags again
(same comment comes here too)
再举一个例子,说我有一个[Y] ENTITY_ID 10,这10 ENTITY_ID与3个标记关联,说: “公交车”, “车” 和“平面“,当我想使用这个entity_id 10查找时,我想要一个与所有这3个标签关联的[x] entity_id列表。 [x] entity_id也可以有额外的标签。
在你的情况下,'x' entity_id可以与一些额外的标签(除了那些3)关联? – ShyJ
是的,它可以。它应该有所有这些标签。可以有更多的少数。 – Sourabh