下面sql语句是否正确,请斧正!

来源:百度知道 编辑:UC知道 时间:2024/06/22 22:11:07
$sql="SELECT count(dinfo_applicationid) as total,dinfo_applicationer FROM `".$table."` WHERE '{left('$apd',4)}' <= '".$endyear."' AND '{left('$apd',4)}' >= '".$beginyear."' AND (".$or.") GROUP BY dinfo_applicationer ORDER BY total DESC limit $temp,20";

'{left('$apd',4)}' <= '".$endyear."' AND '{left('$apd',4)}' >= '".$beginyear."'

年份的判断

AND (".$or.") 就不知到了,除非 (".$or." 是布尔变量,就正确

GROUP BY dinfo_applicationer 分组

ORDER BY total DESC limit $temp,20"; 排序。

改成:ORDER BY count(dinfo_applicationid) DESC limit $temp,20";

这limit $temp,20 几个,因为有分组条件,不能出现在排序中吧

感叹一下
这个问题 属于 妇产科!!!???