Jump to content

Recommended Posts

Could someone help me fix this:
[code]$get_items = "SELECT count(*) AS wood_count, unique_id FROM items WHERE owner = '$cookie_userid' AND location = 'inventory' AND item_id = 22";
if ($db_result = $db_conn->Execute($get_items)) {
    if ($db_result->RecordCount()) {
        while (!$db_result->EOF) {
            $wood_ids[] = $db_result->fields['unique_id'];
        }
        $wood_count = $db_result->fields['wood_count'];
    }
    $db_result->Close();
} else
    die('SQL Error #'.$db_conn->ErrorNo().': '.$db_conn->ErrorMsg());
[/code]

It gives the error
SQL Error #1140: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause

Thanks.
Link to comment
https://forums.phpfreaks.com/topic/5355-mixing-of-group-columns/
Share on other sites

I can't be much more informative than the error you already got. COUNT(*) is a group function, it operates on lots of rows. You can't mix group functions and columns for which you want per-row detail.

You are just trying to get a row count of your result, but that's why there is a mysql_num_rows() function (->RecordCount() with your database wrapper). Use that instead.

[code]$get_items = "SELECT unique_id FROM items WHERE owner = '$cookie_userid' AND location = 'inventory' AND item_id = 22";
if ($db_result = $db_conn->Execute($get_items)) {
    if ($db_result->RecordCount()) {
        while (!$db_result->EOF) {
            $wood_ids[] = $db_result->fields['unique_id'];
        }
        $wood_count = $db_result->RecordCount();
    }
    $db_result->Close();
} else
    die('SQL Error #'.$db_conn->ErrorNo().': '.$db_conn->ErrorMsg());[/code]
Link to comment
https://forums.phpfreaks.com/topic/5355-mixing-of-group-columns/#findComment-19075
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.