Mysqli查询随机选择

How can i randomize my Select Query ?

SELECT *
FROM posts p
INNER JOIN friends f ON (
        (
            p.from_user = f.user1
            OR p.from_user = f.user2
            )
        AND (
            f.user1 = '$ownid'
            OR f.user2 = '$ownid'
            )
        AND f.accepted
        )
WHERE p.from_user != '$ownid'
ORDER BY p.posted_time

Yes i want to hold the query how it is and Ordered by Time but Random cause at the Moment it makes it makes Blocks.

EDIT: Here my Tables for a better understanding

enter image description here

You may consider benefit the PHP rand function: rand():

rand(0,$sql_num_rows)

This function will increase the performance rather than the mysql rand function.