Sometime you may have something to give away to your loyal readers, for most of the cases you are probably going to launch a freebie giveaway competition, ask your readers to comment on the post, and then you will random withdraw the lucky winners. If you are struggled on how to select the winners fairly, besides the random number services, you can have a more professional method to randomly select for WordPress powered blogs from phpMyAdmin dashboard. It’s pretty useful if you know how to use it effectively.

The process of selection involved a fairly simple SQL query to select 5 random comments from specific post. Here’s the simple query example if you want to limit 5 random selection from post ID 265 for the comment ID, comment author name, comment author email and the comment author website URL if they have any from the WordPress comment table.

3 simple steps to random query limit records from specific post:

  1. Login to phpMyAdmin, and select the SQL tab.
  2. paste the code below, you should change the post ID number and limit number.
  3. Click go, the result would generate automatically.
SELECT comment_ID, comment_author, comment_author_email,  comment_author_url
FROM wp_comments
WHERE comment_post_ID = 265
ORDER BY RAND()
LIMIT 5

How do you know the post ID?
Simply login to your WordPress admin dashboard, under the post tab, hover over the post title, you can see the URL showed on the left bottom corner, the number within the URL is exactly the post ID.

Do you like this post?

 Subscribe free via RSS, or by Email to get updates.