{"id":61,"date":"2026-03-06T05:04:29","date_gmt":"2026-03-06T05:04:29","guid":{"rendered":"https:\/\/gigz.pk\/sql\/?post_type=lesson&#038;p=61"},"modified":"2026-03-16T18:47:56","modified_gmt":"2026-03-16T18:47:56","slug":"where-clause","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/sql\/lesson\/where-clause\/","title":{"rendered":"WHERE Clause"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>WHERE clause<\/strong> in SQL is used to filter records in a table based on a specified condition. It allows you to retrieve only the rows that meet certain criteria, making your queries more precise and efficient.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Syntax<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT column1, column2<br>FROM table_name<br>WHERE condition;<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>SELECT<\/strong> specifies the columns to retrieve.<\/li>\n\n\n\n<li><strong>FROM<\/strong> specifies the table to query.<\/li>\n\n\n\n<li><strong>WHERE<\/strong> defines the condition that the rows must satisfy.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Example 1: Basic Filtering<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Retrieve all employees from the &#8220;Employees&#8221; table who work in the &#8220;Sales&#8221; department:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT FirstName, LastName, Department<br>FROM Employees<br>WHERE Department = 'Sales';<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Example 2: Using Comparison Operators<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can use comparison operators such as <code>=<\/code>, <code>&gt;<\/code>, <code>&lt;<\/code>, <code>&gt;=<\/code>, <code>&lt;=<\/code>, <code>&lt;&gt;<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT FirstName, LastName, Salary<br>FROM Employees<br>WHERE Salary &gt; 50000;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Example 3: Using Logical Operators<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Combine multiple conditions using <code>AND<\/code>, <code>OR<\/code>, and <code>NOT<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT FirstName, LastName, Department, Salary<br>FROM Employees<br>WHERE Department = 'Sales' AND Salary &gt; 50000;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Example 4: Using Pattern Matching<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use <code>LIKE<\/code> to search for a specific pattern:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT FirstName, LastName<br>FROM Employees<br>WHERE FirstName LIKE 'J%';<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This retrieves all employees whose first name starts with &#8220;J&#8221;.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example 5: Using NULL Values<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Check for NULL values with <code>IS NULL<\/code> or <code>IS NOT NULL<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">SELECT FirstName, LastName, ManagerID<br>FROM Employees<br>WHERE ManagerID IS NULL;<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Key Points to Remember<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <strong>WHERE clause<\/strong> always comes after the <strong>FROM<\/strong> clause.<\/li>\n\n\n\n<li>Conditions can include columns, constants, and expressions.<\/li>\n\n\n\n<li>Use parentheses <code>()<\/code> to group conditions for complex queries.<\/li>\n\n\n\n<li>Filtering reduces the number of rows returned, improving query performance.<\/li>\n<\/ul>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/sql\/\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">SQL Foundations Program (SQL-101) > Basic Queries > WHERE Clause<\/span><\/span><\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"menu_order":9,"template":"","class_list":["post-61","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>WHERE Clause - SQL Learning Hub<\/title>\n<meta name=\"description\" content=\"Learn how to use the SQL WHERE clause to filter data with conditions, operators, and examples. Easy SQL tutorial for beginners.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/sql\/lesson\/where-clause\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WHERE Clause - SQL Learning Hub\" \/>\n<meta property=\"og:description\" content=\"Learn how to use the SQL WHERE clause to filter data with conditions, operators, and examples. Easy SQL tutorial for beginners.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/sql\/lesson\/where-clause\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Learning Hub\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-16T18:47:56+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/lesson\\\/where-clause\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/lesson\\\/where-clause\\\/\",\"name\":\"WHERE Clause - SQL Learning Hub\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/#website\"},\"datePublished\":\"2026-03-06T05:04:29+00:00\",\"dateModified\":\"2026-03-16T18:47:56+00:00\",\"description\":\"Learn how to use the SQL WHERE clause to filter data with conditions, operators, and examples. Easy SQL tutorial for beginners.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/lesson\\\/where-clause\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/sql\\\/lesson\\\/where-clause\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/lesson\\\/where-clause\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Foundations Program (SQL-101) > Basic Queries > WHERE Clause\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/\",\"name\":\"SQL Learning Hub\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/sql\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WHERE Clause - SQL Learning Hub","description":"Learn how to use the SQL WHERE clause to filter data with conditions, operators, and examples. Easy SQL tutorial for beginners.","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:\/\/gigz.pk\/sql\/lesson\/where-clause\/","og_locale":"en_US","og_type":"article","og_title":"WHERE Clause - SQL Learning Hub","og_description":"Learn how to use the SQL WHERE clause to filter data with conditions, operators, and examples. Easy SQL tutorial for beginners.","og_url":"https:\/\/gigz.pk\/sql\/lesson\/where-clause\/","og_site_name":"SQL Learning Hub","article_modified_time":"2026-03-16T18:47:56+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/gigz.pk\/sql\/lesson\/where-clause\/","url":"https:\/\/gigz.pk\/sql\/lesson\/where-clause\/","name":"WHERE Clause - SQL Learning Hub","isPartOf":{"@id":"https:\/\/gigz.pk\/sql\/#website"},"datePublished":"2026-03-06T05:04:29+00:00","dateModified":"2026-03-16T18:47:56+00:00","description":"Learn how to use the SQL WHERE clause to filter data with conditions, operators, and examples. Easy SQL tutorial for beginners.","breadcrumb":{"@id":"https:\/\/gigz.pk\/sql\/lesson\/where-clause\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/sql\/lesson\/where-clause\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/sql\/lesson\/where-clause\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/sql\/"},{"@type":"ListItem","position":2,"name":"SQL Foundations Program (SQL-101) > Basic Queries > WHERE Clause"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/sql\/#website","url":"https:\/\/gigz.pk\/sql\/","name":"SQL Learning Hub","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/sql\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/sql\/wp-json\/wp\/v2\/lesson\/61","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/sql\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/sql\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/sql\/wp-json\/wp\/v2\/media?parent=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}