日期:2014-05-16  浏览次数:21176 次

关于一个SQL WHERE的问题
写了一个SQL语句,形式如
SELECT filed1,filed2,filed3,COUNT(filed4) AS myFiled FROM table1 LEFT JOIN table2 ON table1.filed1=table2.filed2 WHERE filed1 IN (LIMIT) AND myFiled=1 GROUP BY filed1,filed2,filed3

为什么提示错误:
错误类型:
Microsoft JET Database Engine (0x80040E10)
至少一个参数没有被指定值。
而我把句子中的AND myFiled=1又能正确执行?
求解决办法。!

------解决方案--------------------
SELECT filed1,filed2,filed3,COUNT(filed4) AS myFiled 
FROM table1 LEFT JOIN table2 ON table1.filed1=table2.filed2 
WHERE filed1 IN (LIMIT)
GROUP BY filed1,filed2,filed3
having COUNT(filed4)=1

注意红色部分。
------解决方案--------------------
AND myFiled=1->having COUNT(filed4)=1,对分组结果加条件