Jessica Posted March 20, 2006 Share Posted March 20, 2006 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 errorSQL Error #1140: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clauseThanks. Link to comment https://forums.phpfreaks.com/topic/5355-mixing-of-group-columns/ Share on other sites More sharing options...
wickning1 Posted March 20, 2006 Share Posted March 20, 2006 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 More sharing options...
Jessica Posted March 20, 2006 Author Share Posted March 20, 2006 Thank you. So it's because of the unique_id being in there too? Link to comment https://forums.phpfreaks.com/topic/5355-mixing-of-group-columns/#findComment-19095 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.