sql=" select count(id) as cn from orderitem where wareid=(select id from ware where compid="+getid+")";

解决方案 »

  1.   

    有没有搞错啊wareid=(select id from ware where compid="+getid+")";
    一个字段等于一个数据集么??,大哥用用脑子啊
    这样啊
    sql=" select count(id) as cn from orderitem where wareid in (select id from ware where compid="+getid+")";
      

  2.   

    sql=" select count(id) as cn from orderitem where wareid in (select id from ware where compid="+getid+")";
    多条记录=报错误
      

  3.   

    一个可能是你的记录条数不唯一,还有一个可能就是你的compid字段是字符型的。需要把语句改写成:
    sql=" select count(id) as cn from orderitem where wareid in (select id from ware where compid=''"+getid+"'')"
    还有,你用的是什么语言开发前台啊?又用什么数据库系统啊?