Limit Rows with the WHERE clause – MySQL Beginner Series

This blog post is an excerpt from premium MySQL Beginner content I am creating to help anyone learn how to use MySQL. Thank you for reading and please do provide feedback.

Image by Willi Heidelbach from Pixabay 

✔️ You may also be interested in the blog post, MySQL Beginners Series — The SELECT statement, which is a primer for this article.


Limit Rows with the WHERE clause

So far, we have been executing SELECT * and SELECT column_list types of queries. Not only are we retrieving all of the columns, but, also every row in the FROM clause table is returned. Oftentimes, it is not ideal to retrieve all of a tables’ rows since we may need a more specific set of them.

To filter the returned number of rows from a SELECT query, we use the WHERE clause with one or more search filter conditional tests, constraining the number of rows returned by the FROM clause table.

Comparison Operators

These conditional tests are applied to every row in the FROM clause table against column string, number, or date value data using any one or more of these basic comparisons operators:

  • = : Equals to
  • <> or != : Not equals to
  • < : Less than
  • > : Greater than
  • <= : Less than or equals to
  • >= : Greater than or equals to

(Additional conditional tests are possible using more advanced filtering mechanisms such as: LIKE, IN(), and BETWEEN. However, their discussion is beyond the scope of this introductory article.)

Each conditional test returns one of the following values:

  • TRUE
  • FALSE
  • Unknown

For a row to be included in the result set, its specific conditional test (for however many columns are targeted) must evaluate to TRUE.

Stay tuned – more to come

More articles covering MySQL topics are still to come here on the Digital Owl’s Prose blog. Keep up with all of the premium MySQL Beginner content as I write and release them, along with a weekly MySQL email tip, by exploring the sign-up option below.


Discover premium articles, in-depth guides, instructional videos, and much more by joining the “MySQL Learning Tier” membership. You have access to exclusive content unpublished anywhere else with this membership. With new content being added regularly, continue learning MySQL at any level.


Thank you for reading this post. Please share it with someone else who would enjoy it as well.


Disclaimer: The majority of examples in this post, are performed in a personal development/learning workstation environment and should not be considered production quality or ready. Your particular goals and needs may vary. Like always, just because you can do something doesn’t mean you should. My opinions are my own.


Check out this review on one of my favorite SQL books; Book Recommendation – SQL Antipatterns


More ways I can help

  • Need hosting for your next web application or WordPress site? I highly recommend Hostinger and use them to host my niche bass fishing site. The service is second to none.
  • Desktop and mobile wallpapers, digital downloads, photography services, Shopify and WooCommerce customizations, and content writing – all in one E-commerce Shop. Find your next digital purchase today!
  • Take your Laravel applications next level with Battle Ready Laravel by Ash Allen. Learn how to improve the performance, maintainability, and security of your Laravel projects in this e-book.

Disclosure: Some of this blog post’s services and product links are affiliate links. At no additional cost to you, should you make a purchase by clicking through one of them, I will receive a commission.

Code, content, and community for developers.

The LAMP stack and the PHP technologies and frameworks it runs.

Disclosure: Some of this blog post’s services and product links are affiliate links. At no additional cost to you, should you make a purchase by clicking through one of them, I will receive a commission.

Code, content, and community for developers.

The LAMP stack and the PHP technologies and frameworks it runs.

4 thoughts on “Limit Rows with the WHERE clause – MySQL Beginner Series

  1. Learned, that the result of a SQL query may also be “unknown”, in addition to the familiar boolean values true and false.

    • Absolutely sir. Great point. Thank you for your valuable comment.

Hey thanks for commenting! Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.