我有这个选择:
select 'fv' prefix, c.user, MAX(f.data) as data, c.user, count(c.user) as logs
from favorites f inner join
cadastro c
ON f.user = c.id
where f.fv = '1' and c.user <> f.user and f.data > now()
如果我没有显示结果,mysql会显示:
prefix - user - data - user - logs
fv NULL NULL NULL 0
我不想在没有结果时显示。怎么了?伯爵(c.user)?我怎样才能避免数到0?
答案 0 :(得分:2)
没有select 'fv' as prefix, c.user, MAX(f.data) as data, c.user, count(c.user) as logs
from favorites f inner join
cadastro c
ON f.user = c.id
where f.fv = '1' and c.user <> f.user and f.data > now()
group by f.fv;
的聚合查询总是返回一行。一种简单的方法是添加聚合:
function SublistMouseenter(myAnchorsID) {
if (document.getElementById(myAnchorsID).className == "HeaderCategoryLink") {
document.getElementById(myAnchorsID).className = "header-menu-sublist-hover";
} else {
document.getElementById(myAnchorsID).className = "HeaderCategoryLink";
}
}
如果没有匹配项,则不会返回任何行。