MyBB Community Forums

Full Version: SQLite doesn't support RAND function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
file : inc\functions_user.php

function generate_question() :

SQL = 'SELECT qid, shown FROM ".TABLE_PREFIX."questions WHERE active='1' ORDER BY RAND() LIMIT 1'

generate an error because SQLITE knows RANDOM function but no RAND function Wink


* see http://www.sqlite.org/lang_corefunc.html

more ... I know that questions table is very litle but http://www.carlj.ca/2007/12/16/selecting...-with-sql/

I suggest :

SQL = 'SELECT qid, shown FROM ".TABLE_PREFIX."questions WHERE active='1' ORDER BY RANDOM() LIMIT 1'

but did not test with MySQL or MySQLI.
The commit above wasn't merged, that is the correct one: https://github.com/mybb/mybb/commit/5ece...cb4e0feabd
However this issue is about SQLite, the fix is only working for PostgreSQL.
oh ... sorry : it wasn't a 'support question" : just an issue that I've fixed (for myself) as I said :

RAND -> RANDOM()

and it's fine for me : I succeed to register another member. Wink

... and I tried to find something like "RAND" on the forum before posting.