I am writting plugin where i have custom table. I am trying to access one random row from last 5 rows from this custom table.
"SELECT * FROM $table_name WHERE id > MAX(id)-5 AND id < MAX(id)+1 ORDER BY `time` DESC LIMIT 1";
but does not work. Any solution ?
UPDATE problem sorted as;
$ofset = rand(0, 4);
$read_link_data = "SELECT * FROM $table_name ORDER BY `time` DESC LIMIT $ofset,1";
it works but i suspect is not optimal