Home  >  Article  >  Backend Development  >  这个查询语句应该如何写才正确

这个查询语句应该如何写才正确

WBOY
WBOYOriginal
2016-06-13 12:01:36913browse

这个查询语句应该怎么写才正确
$sns=$db->field('DISTINCT(dname)' AS 'd_name','COUNT(dname)' AS 'tjs')->where(array('lid'=>intval($_GET['id']),'islottery'=>1))->GROUP('dname')->order('tjs DESC')->select();


------解决方案--------------------
DISTINCT 是关键字,而不是函数
不能这样用:DISTINCT(dname)
用了也没效果
但可以放在聚类函数中,比如 count(DISTINCT dname) 统计 dname 有多少种状态

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn