这是一个获取法国谚语的函数:
func (r *proverbRepo) SelectFrByDegree(search string) (proverbs []domain.Proverb, err error) {
rows, err := r.Db.Query(context.Background(), `SELECT ID, proverb
FROM proverbs_fr
WHERE proverb % $1
ORDER BY proverb <-> $1 DESC LIMIT 5
`, search)
if err != nil {
return
}
for rows.Next() {
var prov domain.Proverb
err = rows.Scan(&prov.ID, &prov.Literal)
if err != nil {
return
}
proverbs = append(proverbs, prov)
}
return
}
有时我想从 per say proverbs_bzh 表中获取另一个谚语表。是否可以使用变量名获取不同的表?
SELECT * FROM $1
例如...
小唯快跑啊
相关分类