![](/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.