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'
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'";
用count后,group by 的不全
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中
显示错误 You have an error in your SQL syntax near 'where a.shoppingID=s.shoppingID and a.university='浙江大学' and a.shoppingTime<=' at line 1
COUNT() 是mysql自带的函数啊
count是标准的sql语法中的聚合函数
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
试试我上面给你写的 group by s.goodID,s.goodName,s.originPrice,s.public,s.author,s.OOS 这么多
还是不行啊 显示错误 You have an error in your SQL syntax near 'where a.shoppingID=s.shoppingID and a.university='浙江大学' and a.shoppingTime<=' at line 1
操作环境是:windwos 2k + php + mysql
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
You have an error in your SQL syntax near 'where a.shoppingID=s.shoppingID and a.university='浙江大学' and a.shoppingTime<=' at line 1
显示错误:You have an error in your SQL syntax near 'where a.shoppingID=s.shoppingID and a.university='浙江大学' and a.shoppingTime<=' at line 1
group by s.goodID,s.goodName,s.originPrice,s.public,s.author,s.OOS
这么多
显示错误
You have an error in your SQL syntax near 'where a.shoppingID=s.shoppingID and a.university='浙江大学' and a.shoppingTime<=' at line 1
group by s.goodID,s.goodName,s.originPrice,s.public,s.author,s.OOS 应当先where 后group by
然后在mysql的前端程序里执行这条语句。
然后再看错误信息。
避免因为参数错误而导致的sql语句错。