内容简介:package products import ( "erp/models" "github.com/astaxie/beego/orm" ) type Product_Inventorys struct { Id int64 Name string Formate string Unit string Warehouse string C_name string Purchase string Price string Quantity string } func init() { orm.Registe
多表查询的问题,mysql查询有数据,编写models的时候没传数据(数量是有传值,其他参数没有传值)(models联表查询创建,数据库没有表),各位大神请教下
zhong ·· 2 次点击 ··开始浏览package products import ( "erp/models" "github.com/astaxie/beego/orm" ) type Product_Inventorys struct { Id int64 Name string Formate string Unit string Warehouse string C_name string Purchase string Price string Quantity string } func init() { orm.RegisterModel(new(Product_Inventory)) } //统计仓库存量 func ListInvent()(num int64,err error, invent []Product_Inventorys) { qb, _ := orm.NewQueryBuilder("mysql") qb.Select("i.id As Id", "p.name As Name", " p.format As Formate", "p.unit As Unit","w.w_name As Warehouse","c.name As C_name","p.purchase As Purchase", "p.sales As Price","i.quantity As Quantity"). From(models.TableName("product_inventory i,pms_product p,pms_product_category c,pms_product_warehouse w") ). Where("i.product=p.id and i.warehouse=w.w_id and p.c_id=c.id") sql := qb.String() o := orm.NewOrm() var invents []Product_Inventorys nums, errs := o.Raw(sql).QueryRows(&invents) return nums,errs,invents } [ORM]2019/01/15 20:08:17 -[Queries/default] - [ OK / db.Query / 233.0ms] - [SELECT i.id As Id, p.name As Name, p.format As Formate, p.unit As Unit, w.w_name As Warehouse, c.name As C_name, p.purchase As Purchase, p.sales As Price, i.quantity As Quantity FROM pms_product_inventory i,pms_product p,pms_product_category c,pms_product_warehouse w WHERE i.product=p.id and i.warehouse=w.w_id and p.c_id=c.id] [{0 } {0 } {0 } {0 } {0 } {0 } {0 } {0 } {0 } {0 } {0 }]  
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 数据库MySQL一般查询日志或者慢查询日志历史数据的清理
- 大数据量查询容易 OOM?试试 MySQL 流式查询
- Oracle数据库查询重复数据及删除重复数据方法
- 日志与行为数据存储查询剖析
- 使用Jest查询Elasticsearch数据
- 【数据库】MySQL查询优化
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
实战Java高并发程序设计
葛一鸣、郭超 / 电子工业出版社 / 2015-10-1 / CNY 69.00
在过去单核CPU时代,单任务在一个时间点只能执行单一程序,随着多核CPU的发展,并行程序开发就显得尤为重要。 《实战Java高并发程序设计》主要介绍基于Java的并行程序设计基础、思路、方法和实战。第一,立足于并发程序基础,详细介绍Java中进行并行程序设计的基本方法。第二,进一步详细介绍JDK中对并行程序的强大支持,帮助读者快速、稳健地进行并行程序开发。第三,详细讨论有关“锁”的优化和提高......一起来看看 《实战Java高并发程序设计》 这本书的介绍吧!