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
本文探讨了在SQL语句中使用别名的限制,特别是关于relationId不能作为别名使用,而应使用relation_id的情况。通过一个具体的Go语言示例,展示了如何在数据库查询中正确使用下划线命名的别名。
923

被折叠的 条评论
为什么被折叠?



