I wonder how I can pick one out of the latest three rows from a table.
I have this:
"SELECT * FROM blog_content ORDER BY id DESC LIMIT 0,3"
I thought: save the result in an array and random 0-2 and pick from the array, but that wouldn't work since there's many rows.
If I understand correctly, you want to pick one at random out of the latest 3. Try a subquery:
SELECT * FROM (SELECT * FROM blog_content ORDER BY id DESC LIMIT 0,3) t ORDER BY RAND() LIMIT 1
SELECT * FROM
(SELECT * FROM blog_content ORDER BY id DESC LIMIT 0,3) last_three
ORDER BY RAND() LIMIT 1;
SELECT * FROM (SELECT * FROM blog_content ORDER BY id DESC LIMIT 0,3) AS recentBlogs ORDER BY RAND() LIMIT 1
Worked for me.