1、直接执行sql

sqlPreString=fmt.Sprintf(`INSERT INTO nb_product SET %s%s`,sqlPreString,defaultSql)
_,err=db.SQL(sqlPreString,&content).Execute()

2、like的用法

engine.Where("column like ?", "%"+char+"%").Find

  

3、in的用法,传入的数据要处理一下转为type []interface{}

       db,err:=utils.Db(dbs.C)
	if err!=nil {
		return err
	}
	fmt.Println("%v",ids)
	s := make([]interface{}, len(ids))
	for i, v := range ids {
		s[i] = v
	}
	fmt.Println("%v",s)
	err=db.In("id",s...).Find(product)
	return err

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2021-11-15
  • 2021-12-04
  • 2022-02-12
  • 2021-09-18
  • 2022-01-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-18
  • 2021-06-28
  • 2018-11-13
  • 2021-07-01
  • 2022-12-23
相关资源
相似解决方案