Random record issue, SQLite and MySQL incompatibility

Anyone any ideas on this one?

I use a simple custom query to select a random record but differences between SQLite and MySQL are causing issues.

For SQLIte you have to use random()

Select id from tablename order by random() 

But for MySQL i have to user rand()

Select id from tablename order by rand() 

I have tried setting $_ENV variables like this:

image

and

image

and modifying the query to

But this always returns the first record suggesting the order by is being ignored
So i have to manually set the query when in development then remember to change the query before deploying to Production then change back after

Anyone any ideas how to get around this?

Community Page
Last updated: