如何搜索具有完全相同关系值的集合
我有这3张表服装,服装,appareloutfit (下面的表结构示例)。我想检查使用AppareloutFit Pivot表中的apparel_ids数组是否存在服装。 Apparel_ids的数组应与服装的相关服装_ID完全相同,不再是。我应该怎么做?
-- Apparel --
id | name
-- Outfit --
id | is_favorite
-- ApparelOutfit -- (pivot table)
apparel_id | outfit_id
I have these 3 tables Apparel, Outfit, ApparelOutfit (sample of table structure below). I want to check if an outfit exists using an array of apparel_ids in the ApparelOutfit pivot table. The array of apparel_ids should be exactly the same as the related apparel_ids of the outfit, no more no less. How should I do that?
-- Apparel --
id | name
-- Outfit --
id | is_favorite
-- ApparelOutfit -- (pivot table)
apparel_id | outfit_id
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您的输入通过评论
您可以尝试
EG:
上述查询将获取 Offit1 和 Offit2 ,
对于严格的确切匹配,
例如:
The above query will fetch only outfit1
Based on your input via comment
You can try
Eg:
The above query will fetch outfit1 and outfit2
For a strictly exact match
Eg:
The above query will fetch only outfit1
Laravel Docs - Eloquent Relationships - Querying Relationship Existence