MyBB Community Forums

Full Version: [F] Column averagerating does not exist
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Quote:<error>
<dateline>1219123972</dateline>
<script></script>
<line>0</line>
<type>20</type>
<friendly_type>MyBB SQL Error</friendly_type>
<message>SQL Error: 1054 - Unknown column 'averagerating' in 'order clause'
Query:
SELECT t.*, t.username AS threadusername, u.username
FROM mybb_threads t
LEFT JOIN mybb_users u ON (u.uid = t.uid)
WHERE t.fid='11' AND t.visible='1'
ORDER BY t.sticky DESC, averagerating desc , t.totalratings DESC
LIMIT 0, 20
</message>
</error>
The column averagerating does not exist. The query can be found in the file forumdisplay.php (line 643).
Which SQL Engine?
A user reported this issue in the german community. I'll ask him about that.

But I think it doesn't matter because if you search for "averagerating" in the files mysql_db_tables.php, pgsql_db_tables.php and sqlite_db_tables.php you get no result. But in the file forumdisplay.php you can find this:
        case "rating":
		$t = "";
		$sortfield = "averagerating";
		$sortfield2 = ", t.totalratings DESC";
		break;
Edit: He's using MySQLi.
No, averagerating is simply a reference column created during the query.

$ratingadd = "(t.totalratings/t.numratings) AS averagerating, ";

Ask him to try this
Doesn't work:
Quote:<error>
<dateline>1219297785</dateline>
<script></script>
<line>0</line>
<type>20</type>
<friendly_type>MyBB SQL Error</friendly_type>
<message>SQL Error: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc
LIMIT 0, 20' at line 5
Query:
SELECT t.*, t.username AS threadusername, u.username
FROM mybb_threads t
LEFT JOIN mybb_users u ON (u.uid = t.uid)
WHERE t.fid='24' AND (t.visible='1' OR t.visible='0')
ORDER BY t.sticky DESC, t. desc
LIMIT 0, 20
</message>
</error>
Does this work?
The user still gets this errors.
Quote:<error>
<dateline>1219622893</dateline>
<script></script>
<line>0</line>
<type>20</type>
<friendly_type>MyBB SQL Error</friendly_type>
<message>SQL Error: 1054 - Unknown column 'averagerating' in 'order clause'
Query:
SELECT t.*, t.username AS threadusername, u.username
FROM mybb_threads t
LEFT JOIN mybb_users u ON (u.uid = t.uid)
WHERE t.fid='18' AND t.visible='1'
ORDER BY t.sticky DESC, averagerating asc , t.totalratings DESC
LIMIT 20, 20
</message>
</error>
Alright, I need more information. Tell me how to do this. Give an example or something.
One way to reproduce it is to disable thread ratings in the forum, then try to sort by rating. I could have sworn I reported that as a bug in one of the 1.2 betas... hmm :/
Thank you for your bug report.

This bug has been fixed in our internal code repository. Please note that the problem will not be fixed here until these forums are updated.