![](/img/trans.png)
[英]How do I Fetch Only Parent Records which has @OneToMany Relation with 2 other tables in JPA
[英]How do I fetch all records which belong to a user and show only the records with distinct name?
Tagmap.where(user_id: current_user.id).uniq(:name)
此查询似乎不起作用。 它仍然仅获取属于该用户的所有记录。
您可以使用group by SQL查询。
Tagmap.where(user_id: current_user.id).group(:name)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.