智能选择字段 GORM 允许通过 Select 方法选择特定的字段,如果您在应用程序中经常使用此功能,你也可以定义一个较小的结构体,以实现调用 API 时自动选择特定的字段,例如: type User struct { ID int `gorm:"primaryKey;autoIncrement"` Name sql.NullString `gorm:"default:'隔壁老王'"` Age uint8 `gorm:"default:55"`
离散查询select * from car where price=30 or price=40 or price=50 or price=60;select * from car where price in(30,40,50,60)取出数据select * from car where price not in(30,40,50,60)去掉数据 聚合函数(统计查询)select count(*) from carselect count(code) from car #取所有的数据条数sel