gpt4 book ai didi

php - GROUP BY 功能不起作用

转载 作者:行者123 更新时间:2023-11-29 19:28:44 24 4
gpt4 key购买 nike

更新 wamp php 5.6 和 windows 10...后,GROUP BY 功能不起作用,在 windows 7 和以前的 wamp 上工作正常。代码错误、wamp 错误、windows 错误还是......,还有其他错误吗?

$sql = "SELECT * FROM user JOIN messages ON userID = usertwo WHERE userone = $user GROUP BY usertwo ORDER BY MAX(date) DESC LIMIT 10";
$result = $con->query($sql);

if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {

---不工作

但是如果没有 GROUP BY 和 ()MAX 就可以正常工作

$sql = "SELECT * FROM user JOIN messages ON userID = usertwo WHERE userone = $user  ORDER BY date DESC LIMIT 10";
$result = $con->query($sql);

if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {

最佳答案

谢谢你,你是最好的,在新的 php 5.6 中你必须选择列,不再使用 * ,不能在以前的版本中工作 Lake...

$sql = "从用户 JOIN 消息中选择用户 ID、名字、姓氏 userID = usertwo WHERE userone = $user GROUP BY usertwo ORDER BY MAX(date) DESC LIMIT 10"; $结果 = $con->查询($sql);

                 if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {

感谢:Farkie、krishn patel...

关于php - GROUP BY 功能不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41952780/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com