请帮助我解决此问题。 我的代码:
$dn1 = mysqli_fetch_array(mysqli_query($con, '
select count(id) as recip
, id as recipid
, (select count(*) from pm) as npm
from users
where username="'.$recip.'"'
));
它给出以下错误
错误:在没有GROUP BY的聚合查询中,SELECT的表达式#2 列表包含未聚合的列'omapm.users.id';这是 与sql_mode = only_full_group_by
不兼容
请帮助我更正此问题。 谢谢!
答案 0 :(得分:0)
$dn1 = mysqli_fetch_array(mysqli_query($con,
'select count(id) as recip, id as recipid,
(select count(*) from pm) as npm
from users
where username="'.$recip.'"
group by recipid, npm'));
无论如何,您不应该在sql命令中使用php var ..这样,您就有可能遭受sqlinjection ..您应该为准备好的语句和绑定参数而为自己的mysql驱动程序che一下。