Can I use MySQL functions in the LIMIT
offset?
Like:
SELECT * FROM sites WHERE ... LIMIT FLOOR(1 + RAND() * (SELECT COUNT(*) FROM sites)) , 1
Can I use MySQL functions in the LIMIT
offset?
Like:
SELECT * FROM sites WHERE ... LIMIT FLOOR(1 + RAND() * (SELECT COUNT(*) FROM sites)) , 1
No, you can't do that directly.
LIMIT
andOFFSET
values must be constants.Citation from the MySQL docs:
You can use prepared statements and variables, though: