type RelationIdCount struct {
RelationId int32
Total int64
}
func (d *Dao) GetShareByItemIds(ids []uint) (count []RelationIdCount) {
d.Db.Raw("select user_group_relation_id as relation_id,count(*) as total from item_share WHERE item_id in (?) ", ids).Group("user_group_relation_id").Scan(&count)
return count
}
sql语句里不能用relationId做别名,只能用relation_id
mercurialyk 发布了8 篇原创文章 · 获赞 0 · 访问量 566 私信 关注