Here is how I query my database for some words
$query = $qb->select(\'w\') ->from(\'DbEntities\\Entity\\Word\', \'w\') ->where(\'w.indiction
First get the MAX value from DB table & then use this as offset in PHP i.e $offset = mt_rand(1, $maxId)