Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12141

How to get distinct results using GORM

$
0
0

In Go, I write a query that gives me all data but I just want to data where products.id and clients.id are distinct.What is the simile query I can write?

res := find.Model(&domain.Clients{}).    Select ("products.id product_id, products.name product_name,"+" clients.id id, clients.name name, clients.logo, clients.address, "+"clients.business_id, clients.num_of_employee, clients.email, clients.sns_link, clients.phone").    Joins("LEFT JOIN company_interests ON company_interests.client_id = clients.id").    Joins("LEFT JOIN products ON products.id = company_interests.product_id").    Where("products.id = ? ", productId).Find(&resp)

Viewing all articles
Browse latest Browse all 12141

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>