当前位置: 代码迷 >> Java Web开发 >> 新手求大侠帮忙,column 'typeid' in where clause is ambiguous是咋回事
  详细解决方案

新手求大侠帮忙,column 'typeid' in where clause is ambiguous是咋回事

热度:387   发布时间:2016-04-17 10:19:00.0
新手求大侠帮忙,column 'typeid' in where clause is ambiguous是怎么回事?
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();}}}
  相关解决方案