{"id":3555,"date":"2023-04-12T15:39:23","date_gmt":"2023-04-12T15:39:23","guid":{"rendered":"https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/"},"modified":"2026-01-15T18:20:54","modified_gmt":"2026-01-15T18:20:54","slug":"basic-sql-functions-part-2-where-statement","status":"publish","type":"post","link":"https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/","title":{"rendered":"How Do I Use the SQL WHERE Statement to Filter Query Results?"},"content":{"rendered":"<p>Now that we have talked about how to specify what columns we would like to see in a view, we can talk about how to control the records or rows. The WHERE clause is a very useful one and it allows us to only view records that fit a certain criterion. The criteria often times involves some sort of logic or a conditional statement following it. For the purpose of this tutorial we will use very simple logic although you can get very particular and use some complicated conditions to achieve exactly what you are looking for.<\/p>\n<p>An important thing to note when writing SQL queries is the order in which you are writing the clauses. You may have noticed in the last tutorial the from clause came after the select clause. SQL has a bit of an intuitive way of working, think of it by saying \u201cLets look at these columns, from this table\u201d but boiling that down into a very concise syntax that a computer can understand. Now we are adding one more clause to the mix; the WHERE clause occurs after the from statement, think \u201cLets look at these columns, from this table, where I can only see transactions that are more than 100 dollars\u201d Let\u2019s look at an example that accomplishes this train of thought.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1039 aligncenter\" src=\"https:\/\/quebit.com\/askquebit\/wp-content\/uploads\/2020\/06\/P2A-251x300.jpg\" alt=\"\" width=\"251\" height=\"300\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Click here for <a href=\"https:\/\/quebit.com\/askquebit\/quebit-products\/basic-sql-functions-part-2-where-statement\/\">Part 3: GROUP BY statement<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Now that we have talked about how to specify what columns we would like to see in a view, we can talk about how to control the records or rows. The WHERE clause is a very useful one and it allows us to only view records that fit a certain criterion. The criteria often times&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[27],"tags":[32],"class_list":["post-3555","post","type-post","status-publish","format-standard","hentry","category-quebit-value","tag-sql"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How Do I Use the SQL WHERE Statement to Filter Query Results? - QueBIT<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How Do I Use the SQL WHERE Statement to Filter Query Results? - QueBIT\" \/>\n<meta property=\"og:description\" content=\"Now that we have talked about how to specify what columns we would like to see in a view, we can talk about how to control the records or rows. The WHERE clause is a very useful one and it allows us to only view records that fit a certain criterion. The criteria often times&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/\" \/>\n<meta property=\"og:site_name\" content=\"QueBIT\" \/>\n<meta property=\"article:published_time\" content=\"2023-04-12T15:39:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-15T18:20:54+00:00\" \/>\n<meta name=\"author\" content=\"agoddard\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"agoddard\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/basic-sql-functions-part-2-where-statement\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/basic-sql-functions-part-2-where-statement\\\/\"},\"author\":{\"name\":\"agoddard\",\"@id\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/#\\\/schema\\\/person\\\/e52d72da0fd2f5f70d189343fe4f5084\"},\"headline\":\"How Do I Use the SQL WHERE Statement to Filter Query Results?\",\"datePublished\":\"2023-04-12T15:39:23+00:00\",\"dateModified\":\"2026-01-15T18:20:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/basic-sql-functions-part-2-where-statement\\\/\"},\"wordCount\":239,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/basic-sql-functions-part-2-where-statement\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/P2A-251x300.jpg\",\"keywords\":[\"SQL\"],\"articleSection\":[\"QueBIT Value\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/quebit.com\\\/askquebit\\\/basic-sql-functions-part-2-where-statement\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/basic-sql-functions-part-2-where-statement\\\/\",\"url\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/basic-sql-functions-part-2-where-statement\\\/\",\"name\":\"How Do I Use the SQL WHERE Statement to Filter Query Results? - QueBIT\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/basic-sql-functions-part-2-where-statement\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/basic-sql-functions-part-2-where-statement\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/P2A-251x300.jpg\",\"datePublished\":\"2023-04-12T15:39:23+00:00\",\"dateModified\":\"2026-01-15T18:20:54+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/#\\\/schema\\\/person\\\/e52d72da0fd2f5f70d189343fe4f5084\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/basic-sql-functions-part-2-where-statement\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/quebit.com\\\/askquebit\\\/basic-sql-functions-part-2-where-statement\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/basic-sql-functions-part-2-where-statement\\\/#primaryimage\",\"url\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/P2A-251x300.jpg\",\"contentUrl\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/wp-content\\\/uploads\\\/2020\\\/06\\\/P2A-251x300.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/basic-sql-functions-part-2-where-statement\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How Do I Use the SQL WHERE Statement to Filter Query Results?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/#website\",\"url\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/\",\"name\":\"QueBIT\",\"description\":\"QueBIT\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/#\\\/schema\\\/person\\\/e52d72da0fd2f5f70d189343fe4f5084\",\"name\":\"agoddard\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d817b364cff1d66116debde8d1c85e5e76eeece9c5ae731b19276a6040231455?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d817b364cff1d66116debde8d1c85e5e76eeece9c5ae731b19276a6040231455?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d817b364cff1d66116debde8d1c85e5e76eeece9c5ae731b19276a6040231455?s=96&d=mm&r=g\",\"caption\":\"agoddard\"},\"sameAs\":[\"https:\\\/\\\/quebit.com\\\/askquebit\"],\"url\":\"https:\\\/\\\/quebit.com\\\/askquebit\\\/author\\\/agoddard\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How Do I Use the SQL WHERE Statement to Filter Query Results? - QueBIT","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/","og_locale":"en_US","og_type":"article","og_title":"How Do I Use the SQL WHERE Statement to Filter Query Results? - QueBIT","og_description":"Now that we have talked about how to specify what columns we would like to see in a view, we can talk about how to control the records or rows. The WHERE clause is a very useful one and it allows us to only view records that fit a certain criterion. The criteria often times&hellip;","og_url":"https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/","og_site_name":"QueBIT","article_published_time":"2023-04-12T15:39:23+00:00","article_modified_time":"2026-01-15T18:20:54+00:00","author":"agoddard","twitter_card":"summary_large_image","twitter_misc":{"Written by":"agoddard","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/#article","isPartOf":{"@id":"https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/"},"author":{"name":"agoddard","@id":"https:\/\/quebit.com\/askquebit\/#\/schema\/person\/e52d72da0fd2f5f70d189343fe4f5084"},"headline":"How Do I Use the SQL WHERE Statement to Filter Query Results?","datePublished":"2023-04-12T15:39:23+00:00","dateModified":"2026-01-15T18:20:54+00:00","mainEntityOfPage":{"@id":"https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/"},"wordCount":239,"commentCount":0,"image":{"@id":"https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/#primaryimage"},"thumbnailUrl":"https:\/\/quebit.com\/askquebit\/wp-content\/uploads\/2020\/06\/P2A-251x300.jpg","keywords":["SQL"],"articleSection":["QueBIT Value"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/","url":"https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/","name":"How Do I Use the SQL WHERE Statement to Filter Query Results? - QueBIT","isPartOf":{"@id":"https:\/\/quebit.com\/askquebit\/#website"},"primaryImageOfPage":{"@id":"https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/#primaryimage"},"image":{"@id":"https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/#primaryimage"},"thumbnailUrl":"https:\/\/quebit.com\/askquebit\/wp-content\/uploads\/2020\/06\/P2A-251x300.jpg","datePublished":"2023-04-12T15:39:23+00:00","dateModified":"2026-01-15T18:20:54+00:00","author":{"@id":"https:\/\/quebit.com\/askquebit\/#\/schema\/person\/e52d72da0fd2f5f70d189343fe4f5084"},"breadcrumb":{"@id":"https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/#primaryimage","url":"https:\/\/quebit.com\/askquebit\/wp-content\/uploads\/2020\/06\/P2A-251x300.jpg","contentUrl":"https:\/\/quebit.com\/askquebit\/wp-content\/uploads\/2020\/06\/P2A-251x300.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/quebit.com\/askquebit\/basic-sql-functions-part-2-where-statement\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/quebit.com\/askquebit\/"},{"@type":"ListItem","position":2,"name":"How Do I Use the SQL WHERE Statement to Filter Query Results?"}]},{"@type":"WebSite","@id":"https:\/\/quebit.com\/askquebit\/#website","url":"https:\/\/quebit.com\/askquebit\/","name":"QueBIT","description":"QueBIT","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/quebit.com\/askquebit\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/quebit.com\/askquebit\/#\/schema\/person\/e52d72da0fd2f5f70d189343fe4f5084","name":"agoddard","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d817b364cff1d66116debde8d1c85e5e76eeece9c5ae731b19276a6040231455?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d817b364cff1d66116debde8d1c85e5e76eeece9c5ae731b19276a6040231455?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d817b364cff1d66116debde8d1c85e5e76eeece9c5ae731b19276a6040231455?s=96&d=mm&r=g","caption":"agoddard"},"sameAs":["https:\/\/quebit.com\/askquebit"],"url":"https:\/\/quebit.com\/askquebit\/author\/agoddard\/"}]}},"_links":{"self":[{"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/posts\/3555","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/comments?post=3555"}],"version-history":[{"count":1,"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/posts\/3555\/revisions"}],"predecessor-version":[{"id":4924,"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/posts\/3555\/revisions\/4924"}],"wp:attachment":[{"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/media?parent=3555"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/categories?post=3555"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/quebit.com\/askquebit\/wp-json\/wp\/v2\/tags?post=3555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}