String sql = "select s_commodityStockpile.c_id,s_commodityStockpile.commodityCode,s_commodityStockpile.commodityName,s_commodityStockpile.oldAmount,s_commodityStockpile.alterationAmount,s_commodityStockpile.remark, s_commodity.color,s_commodity. model " +
"from s_commodityStockpile " +
"left join s_commodity on s_commodity.c_id=s_commodityStockpile.c_id "+
"where s_commodity.c_id=s_commodityStockpile.c_id ";
说什么两个表有共同的名字的字段。怎么改啊?新手求大侠帮忙。
------解决方案--------------------
- Java code
//查询商品库存public static void dg1DataBind(DataGridAction dla){try{String commodityCode = dla.getParam("commodityCode");//String sex = dla.getParam("sex");String commodityName = dla.getParam("commodityName");String sql = "select s_commodityStockpile.c_id,s_commodityStockpile.commodityCode,s_commodityStockpile.commodityName,s_commodityStockpile.oldAmount,s_commodityStockpile.alterationAmount,s_commodityStockpile.remark, s_commodity.color,s_commodity. model " +"from s_commodityStockpile " +"left join s_commodity on s_commodity.c_id=s_commodityStockpile.c_id "+"where s_commodityStockpile.c_id = s_commodity.c_id";if(StringUtil.isNotEmpty(commodityCode)){sql += " and commodityCode='"+commodityCode+"'";}if(StringUtil.isNotEmpty(commodityName)){sql += " and s_commodityStockpile.commodityName='"+commodityName+"'";}dla.setTotal(new QueryBuilder(sql));DataTable dt = new QueryBuilder(sql).executePagedDataTable(dla.getPageSize(),dla.getPageIndex());dla.bindData(dt);}catch(Exception e){dla.bindData(new DataTable());e.printStackTrace();}}}