是sql查询语句,不知道错在哪儿

解决方案 »

  1.   

    select s.goodID,s.goodName,s.originPrice,s.public,s.author,s.OOS,COUNT(s.quality) as quality from sellgoodsinfo as s,appendinfo as a group by s.goodName,s.public,s.author where a.shoppingID=s.shoppingID and a.university='$university' and a.shoppingTime<='$maxdate' and a.shoppingTime>='$maxdate'
      

  2.   

    You should do like this:$sql = "select s.goodID,s.goodName,s.originPrice,s.public,s.author,s.OOS,COUNT(s.quality) as quality from sellgoodsinfo s,appendinfo a group by s.goodName,s.public,s.author where a.shoppingID=s.shoppingID and a.university='$university' and a.shoppingTime<='$maxdate' and a.shoppingTime>='$maxdate'";
      

  3.   

    用count后,group by 的不全
      

  4.   

    select s.goodID,s.goodName,s.originPrice,s.public,s.author,s.OOS,COUNT(s.quality) as quality from sellgoodsinfo as s,appendinfo as a group by s.goodID,s.goodName,s.originPrice,s.public,s.author,s.OOS where a.shoppingID=s.shoppingID and a.university='$university' and a.shoppingTime<='$maxdate' and a.shoppingTime>='$maxdate'就是,你没有count的字段,都要放到group by中
      

  5.   

    显示错误
    You have an error in your SQL syntax near 'where a.shoppingID=s.shoppingID and a.university='浙江大学' and a.shoppingTime<=' at line 1
      

  6.   

    COUNT() 是mysql自带的函数啊
      

  7.   

    count是标准的sql语法中的聚合函数
      

  8.   

    select s.goodID,s.goodName,s.originPrice,s.public,s.author,s.OOS,COUNT(*) as quality from sellgoodsinfo  s,appendinfo  a group by s.goodName,s.public,s.author where a.shoppingID=s.shoppingID and a.university='$university' and a.shoppingTime<='$maxdate' and a.shoppingTime>='$maxdate'
    显示错误:You have an error in your SQL syntax near 'where a.shoppingID=s.shoppingID and a.university='浙江大学' and a.shoppingTime<=' at line 1
      

  9.   

    试试我上面给你写的
    group by s.goodID,s.goodName,s.originPrice,s.public,s.author,s.OOS
    这么多
      

  10.   

    还是不行啊
    显示错误
    You have an error in your SQL syntax near 'where a.shoppingID=s.shoppingID and a.university='浙江大学' and a.shoppingTime<=' at line 1
      

  11.   

    操作环境是:windwos 2k  +  php + mysql
      

  12.   

    select s.goodID,s.goodName,s.originPrice,s.public,s.author,s.OOS,COUNT(s.quality) as quality from sellgoodsinfo as s,appendinfo as a where a.shoppingID=s.shoppingID and a.university='$university' and a.shoppingTime<='$maxdate' and a.shoppingTime>='$maxdate'
    group by s.goodID,s.goodName,s.originPrice,s.public,s.author,s.OOS 应当先where 后group by
      

  13.   

    a.shoppingTime 是日期类型的吗?应该用函数todate()加以转换成日期类型的数据,a.shoppingTime <= to_date('$maxdate','YYYY-MM-DD HH:MM:SS')
      

  14.   

    把生成的sql语句显示出来看。
    然后在mysql的前端程序里执行这条语句。
    然后再看错误信息。
    避免因为参数错误而导致的sql语句错。