{"id":90,"date":"2016-03-22T13:00:13","date_gmt":"2016-03-22T13:00:13","guid":{"rendered":"https:\/\/sqltutorial.org\/?page_id=90"},"modified":"2025-02-04T07:20:23","modified_gmt":"2025-02-04T14:20:23","slug":"sql-where","status":"publish","type":"page","link":"https:\/\/www.sqltutorial.org\/sql-where\/","title":{"rendered":"SQL WHERE"},"content":{"rendered":"\r\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to use the SQL <code>WHERE<\/code> clause to filter rows based on one or more conditions.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='introduction-to-sql-where-clause'>Introduction to SQL WHERE clause <a href=\"#introduction-to-sql-where-clause\" class=\"anchor\" id=\"introduction-to-sql-where-clause\" title=\"Anchor for Introduction to SQL WHERE clause\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>To select specific rows from a table based on one or more conditions, you use the <code>WHERE<\/code> clause in the <code><a href=\"https:\/\/www.sqltutorial.org\/sql-select\/\">SELECT<\/a><\/code> statement.<\/p>\r\n\r\n\r\n\r\n<p>Here&#8217;s the syntax of the <code>WHERE<\/code> clause:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> \r\n    column1, column2, ...\r\n<span class=\"hljs-keyword\">FROM<\/span>\r\n    table_name\r\n<span class=\"hljs-keyword\">WHERE<\/span>\r\n    condition;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>The <code>WHERE<\/code> clause appears immediately after the <code>FROM<\/code> clause.\u00a0It contains one or more Boolean expressions that evaluate each row in the table.<\/p>\r\n\r\n\r\n\r\n<p>If a row that causes the condition evaluates to <code>true<\/code>, the query will include that row in the result set.<\/p>\r\n\r\n\r\n\r\n<p class=\"note\">Note that SQL has three-valued logic which are <code>true<\/code>, <code>false<\/code>, and <code>NULL<\/code>. It means that if a row causes the <code>condition<\/code> to evaluate to <code>false<\/code> or <code>null<\/code>, the query will not include that row in the result set.<\/p>\r\n\r\n\r\n\r\n<p>The condition that follows the <code>WHERE<\/code> clause is also known as a predicate. You can use operators to form a flexible condition to filter rows.<\/p>\r\n\r\n\r\n\r\n<p>The following table shows the <a href=\"https:\/\/www.sqltutorial.org\/sql-comparison-operators\/\">SQL comparison operators<\/a>:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-table\">\r\n<table>\r\n<thead>\r\n<tr>\r\n<th>Operator<\/th>\r\n<th>Meaning<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<td>=<\/td>\r\n<td>Equal to<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&lt;&gt; (!=)<\/td>\r\n<td>Not equal to<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&lt;<\/td>\r\n<td>Less than<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&gt;<\/td>\r\n<td>Greater than<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&lt;=<\/td>\r\n<td>Less than or equal<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>&gt;=<\/td>\r\n<td>Greater than or equal<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/figure>\r\n\r\n\r\n\r\n<p>To construct a simple condition, you use one of the operators above with two operands that can be column name on one side and a literal value on the other, for example:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">salary &gt; 1000<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>It asks the question: &#8220;Is salary greater than 1000?&#8221;.<\/p>\r\n\r\n\r\n\r\n<p>Or you can use column names on both sides of an operator such as:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">min_salary &lt; max_salary<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>This expression asks another question: &#8220;Is the minimum salary less than the maximum salary?&#8221;.<\/p>\r\n\r\n\r\n\r\n<p>The literal values you use in a condition can be numbers, strings, dates, and times. Here are typical formats:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>Numbers can be an integer or a decimal without any formatting e.g., <code>100<\/code>, <code>123.45<\/code><\/li>\r\n\r\n\r\n\r\n<li>Strings are surrounded by single quotes e.g., <code>'100'<\/code>, <code>'John Doe'<\/code>.<\/li>\r\n\r\n\r\n\r\n<li>Dates depend on database systems, but the common format is <code>'yyyy-mm-dd'<\/code>.<\/li>\r\n\r\n\r\n\r\n<li>Time uses <code>'HH:MM:SS'<\/code> to represent a time value.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>Besides the <code>SELECT<\/code> statement, you can use the <code>WHERE<\/code> clause in the <code><a href=\"https:\/\/www.sqltutorial.org\/sql-update\/\">UPDATE<\/a><\/code> or <code><a href=\"https:\/\/www.sqltutorial.org\/sql-delete\/\">DELETE<\/a><\/code> statement to specify which rows to update or delete.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='sql-where-clause-examples'>SQL WHERE clause examples <a href=\"#sql-where-clause-examples\" class=\"anchor\" id=\"sql-where-clause-examples\" title=\"Anchor for SQL WHERE clause examples\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>We will use the <code>employees<\/code> table to demonstrate how to filter rows using the <code>WHERE<\/code> clause.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"169\" height=\"273\" class=\"wp-image-237\" src=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/03\/employees.png\" alt=\"SQL WHERE Clause: Employees Table\" \/><\/figure>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\" id='filtering-rows-based-on-numeric-values'>Filtering rows based on numeric values <a href=\"#filtering-rows-based-on-numeric-values\" class=\"anchor\" id=\"filtering-rows-based-on-numeric-values\" title=\"Anchor for Filtering rows based on numeric values\">#<\/a><\/h3>\r\n\r\n\r\n\r\n<p>The following query uses the <code>WHERE<\/code> clause to select employees who have salaries greater than <code>14,000<\/code> :<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span>\r\n  employee_id,\r\n  first_name,\r\n  last_name,\r\n  salary\r\n<span class=\"hljs-keyword\">FROM<\/span>\r\n  employees\r\n<span class=\"hljs-keyword\">WHERE<\/span>\r\n  salary &gt; <span class=\"hljs-number\">14000<\/span>\r\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span>\r\n  salary <span class=\"hljs-keyword\">DESC<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p><a href=\"https:\/\/www.sqltutorial.org\/playground\/?q=U0VMRUNUIGVtcGxveWVlX2lkLCBmaXJzdF9uYW1lLCBsYXN0X25hbWUsIHNhbGFyeSBGUk9NIGVtcGxveWVlcyBXSEVSRSBzYWxhcnkgPiAxNDAwMCBPUkRFUiBCWSBzYWxhcnkgREVTQzs%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\r\n\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\"> employee_id | first_name | last_name |  salary\r\n-------------+------------+-----------+----------\r\n         100 | Steven     | King      | 24000.00\r\n         101 | Neena      | Kochhar   | 17000.00\r\n         102 | Lex        | De Haan   | 17000.00<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<h3 class=\"wp-block-heading\" id='filtering-rows-based-on-string-values'>Filtering rows based on string values <a href=\"#filtering-rows-based-on-string-values\" class=\"anchor\" id=\"filtering-rows-based-on-string-values\" title=\"Anchor for Filtering rows based on string values\">#<\/a><\/h3>\r\n\r\n\r\n\r\n<p>The following statement uses the <code>WHERE<\/code> clause to find employees with the last name is <code>Chen<\/code>.<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span>\r\n  employee_id,\r\n  first_name,\r\n  last_name\r\n<span class=\"hljs-keyword\">FROM<\/span>\r\n  employees\r\n<span class=\"hljs-keyword\">WHERE<\/span>\r\n  last_name = <span class=\"hljs-string\">'Chen'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p><a href=\"https:\/\/www.sqltutorial.org\/playground\/?q=U0VMRUNUIGVtcGxveWVlX2lkLCBmaXJzdF9uYW1lLCBsYXN0X25hbWUgRlJPTSBlbXBsb3llZXMgV0hFUkUgbGFzdF9uYW1lID0gJ0NoZW4nOw%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\r\n\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\"> employee_id | first_name | last_name\r\n-------------+------------+-----------\r\n         110 | John       | Chen<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>When comparing values, SQL matches string case-sensitively.<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\" id='filtering-rows-based-on-dates'>Filtering rows based on dates <a href=\"#filtering-rows-based-on-dates\" class=\"anchor\" id=\"filtering-rows-based-on-dates\" title=\"Anchor for Filtering rows based on dates\">#<\/a><\/h3>\r\n\r\n\r\n\r\n<p>The following query uses a <code>WHERE<\/code> clause to find all employees who joined the company after <code>January 1, 1999<\/code> :<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span>\r\n  first_name,\r\n  last_name,\r\n  hire_date\r\n<span class=\"hljs-keyword\">FROM<\/span>\r\n  employees\r\n<span class=\"hljs-keyword\">WHERE<\/span>\r\n  hire_date &gt;= <span class=\"hljs-string\">'1999-01-01'<\/span>\r\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span>\r\n  hire_date <span class=\"hljs-keyword\">DESC<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p><a href=\"https:\/\/www.sqltutorial.org\/playground\/?q=U0VMRUNUIGZpcnN0X25hbWUsIGxhc3RfbmFtZSwgaGlyZV9kYXRlIEZST00gZW1wbG95ZWVzIFdIRVJFIGhpcmVfZGF0ZSA%2BPSAnMTk5OS0wMS0wMScgT1JERVIgQlkgaGlyZV9kYXRlIERFU0M7\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\"> first_name | last_name  | hire_date\r\n------------+------------+------------\r\n Charles    | Johnson    | 2000-01-04\r\n Luis       | Popp       | 1999-12-07\r\n Karen      | Colmenares | 1999-08-10\r\n Kimberely  | Grant      | 1999-05-24\r\n Diana      | Lorentz    | 1999-02-07<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p>If you want to find the employees who joined the company in <code>1999<\/code>, you can use one of the following options:<\/p>\r\n\r\n\r\n\r\n<ol class=\"wp-block-list\">\r\n<li>Use the <code>EXTRACT<\/code> function to extract the year from the <code>hire_date<\/code> column and use the equal to (<code>=<\/code>) operator in the expression.<\/li>\r\n\r\n\r\n\r\n<li>Use two expressions with the <code><a href=\"https:\/\/www.sqltutorial.org\/sql-and\/\">AND<\/a><\/code> operator that compares the hire date with <code>Jan 1, 1999 <\/code>and <code>Dec 31, 1999<\/code>.<\/li>\r\n\r\n\r\n\r\n<li>Use the <code><a href=\"https:\/\/www.sqltutorial.org\/sql-between\/\">BETWEEN<\/a><\/code> operator.<\/li>\r\n<\/ol>\r\n\r\n\r\n\r\n<p>The following statement uses the <code>EXTRACT<\/code> function to get the year and compare it with <code>1999<\/code> in the <code>WHERE<\/code> clause:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span>\r\n  first_name,\r\n  last_name,\r\n  hire_date\r\n<span class=\"hljs-keyword\">FROM<\/span>\r\n  employees\r\n<span class=\"hljs-keyword\">WHERE<\/span>\r\n  <span class=\"hljs-keyword\">EXTRACT<\/span>(<span class=\"hljs-keyword\">YEAR<\/span> <span class=\"hljs-keyword\">FROM<\/span> hire_date) = <span class=\"hljs-number\">1999<\/span>\r\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span>\r\n  hire_date <span class=\"hljs-keyword\">DESC<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<p><a href=\"https:\/\/www.sqltutorial.org\/playground\/?q=U0VMRUNUIGZpcnN0X25hbWUsIGxhc3RfbmFtZSwgaGlyZV9kYXRlIEZST00gZW1wbG95ZWVzIFdIRVJFIEVYVFJBQ1QoWUVBUiBGUk9NIGhpcmVfZGF0ZSkgPSAxOTk5IE9SREVSIEJZIGhpcmVfZGF0ZSBERVNDOw%3D%3D\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\r\n\r\n\r\n\r\n<p>Output:<\/p>\r\n\r\n\r\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\"> first_name | last_name  | hire_date\r\n------------+------------+------------\r\n Luis       | Popp       | 1999-12-07\r\n Karen      | Colmenares | 1999-08-10\r\n Kimberely  | Grant      | 1999-05-24\r\n Diana      | Lorentz    | 1999-02-07<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">plaintext<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">plaintext<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li>Use the <code>WHERE<\/code> clause to filter rows based on one or more conditions.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='databases'>Databases <a href=\"#databases\" class=\"anchor\" id=\"databases\" title=\"Anchor for Databases\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li><a href=\"https:\/\/www.pgtutorial.com\/postgresql-tutorial\/postgresql-where\/\" target=\"_blank\" rel=\"noreferrer noopener\">PostgreSQL WHERE clause<\/a><\/li>\r\n\r\n\r\n\r\n<li><a href=\"https:\/\/www.oracletutorial.com\/oracle-basics\/oracle-where\/\" target=\"_blank\" rel=\"noreferrer noopener\">Oracle WHERE clause<\/a><\/li>\r\n\r\n\r\n\r\n<li><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-where\/\" target=\"_blank\" rel=\"noreferrer noopener\">SQL Server WHERE clause<\/a><\/li>\r\n\r\n\r\n\r\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/\" target=\"_blank\" rel=\"noreferrer noopener\">MySQL WHERE clause<\/a><\/li>\r\n\r\n\r\n\r\n<li><a href=\"https:\/\/www.sqlitetutorial.net\/sqlite-where\/\" target=\"_blank\" rel=\"noreferrer noopener\">SQLite WHERE clause<\/a><\/li>\r\n\r\n\r\n\r\n<li><a href=\"https:\/\/www.db2tutorial.com\/db2-basics\/db2-where\/\" target=\"_blank\" rel=\"noreferrer noopener\">Db2 WHERE clause<\/a><\/li>\r\n\r\n\r\n\r\n<li><a href=\"https:\/\/www.mariadbtutorial.com\/mariadb-basics\/mariadb-where\/\" target=\"_blank\" rel=\"noreferrer noopener\">MariaDB WHERE clause<\/a><\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='quiz'>Quiz <a href=\"#quiz\" class=\"anchor\" id=\"quiz\" title=\"Anchor for Quiz\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p><iframe loading=\"lazy\" class=\"iframe\" src=\"\/quiz\/?quiz=where\" name=\"quiz\" width=\"600\" height=\"700\"><\/iframe><\/p>\r\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"90\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqltutorial.org\/sql-where\/\"\n\t\t\t\tdata-post-title=\"SQL WHERE\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"90\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqltutorial.org\/sql-where\/\"\n\t\t\t\tdata-post-title=\"SQL WHERE\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows you how to use the SQL WHERE clause to filter rows from a table based on a specified condition.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":8,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-90","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SQL WHERE Clause<\/title>\n<meta name=\"description\" content=\"This tutorial shows you how to use the SQL WHERE clause to filter rows from a query based on one or more conditions.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqltutorial.org\/sql-where\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL WHERE Clause\" \/>\n<meta property=\"og:description\" content=\"This tutorial shows you how to use the SQL WHERE clause to filter rows from a query based on one or more conditions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqltutorial.org\/sql-where\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-04T14:20:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/03\/employees.png\" \/>\n\t<meta property=\"og:image:width\" content=\"169\" \/>\n\t<meta property=\"og:image:height\" content=\"273\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\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=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqltutorial.org\/sql-where\/\",\"url\":\"https:\/\/www.sqltutorial.org\/sql-where\/\",\"name\":\"SQL WHERE Clause\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqltutorial.org\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.sqltutorial.org\/sql-where\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.sqltutorial.org\/sql-where\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/03\/employees.png\",\"datePublished\":\"2016-03-22T13:00:13+00:00\",\"dateModified\":\"2025-02-04T14:20:23+00:00\",\"description\":\"This tutorial shows you how to use the SQL WHERE clause to filter rows from a query based on one or more conditions.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.sqltutorial.org\/sql-where\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqltutorial.org\/sql-where\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqltutorial.org\/sql-where\/#primaryimage\",\"url\":\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/03\/employees.png\",\"contentUrl\":\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/03\/employees.png\",\"width\":169,\"height\":273,\"caption\":\"SQL Correlated Subquery - employees table\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqltutorial.org\/sql-where\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqltutorial.org\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL WHERE\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqltutorial.org\/#website\",\"url\":\"https:\/\/www.sqltutorial.org\/\",\"name\":\"SQL Tutorial\",\"description\":\"An Interactive SQL Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqltutorial.org\/?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":"SQL WHERE Clause","description":"This tutorial shows you how to use the SQL WHERE clause to filter rows from a query based on one or more conditions.","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:\/\/www.sqltutorial.org\/sql-where\/","og_locale":"en_US","og_type":"article","og_title":"SQL WHERE Clause","og_description":"This tutorial shows you how to use the SQL WHERE clause to filter rows from a query based on one or more conditions.","og_url":"https:\/\/www.sqltutorial.org\/sql-where\/","og_site_name":"SQL Tutorial","article_modified_time":"2025-02-04T14:20:23+00:00","og_image":[{"width":169,"height":273,"url":"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/03\/employees.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqltutorial.org\/sql-where\/","url":"https:\/\/www.sqltutorial.org\/sql-where\/","name":"SQL WHERE Clause","isPartOf":{"@id":"https:\/\/www.sqltutorial.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqltutorial.org\/sql-where\/#primaryimage"},"image":{"@id":"https:\/\/www.sqltutorial.org\/sql-where\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/03\/employees.png","datePublished":"2016-03-22T13:00:13+00:00","dateModified":"2025-02-04T14:20:23+00:00","description":"This tutorial shows you how to use the SQL WHERE clause to filter rows from a query based on one or more conditions.","breadcrumb":{"@id":"https:\/\/www.sqltutorial.org\/sql-where\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqltutorial.org\/sql-where\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqltutorial.org\/sql-where\/#primaryimage","url":"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/03\/employees.png","contentUrl":"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/03\/employees.png","width":169,"height":273,"caption":"SQL Correlated Subquery - employees table"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqltutorial.org\/sql-where\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"SQL WHERE"}]},{"@type":"WebSite","@id":"https:\/\/www.sqltutorial.org\/#website","url":"https:\/\/www.sqltutorial.org\/","name":"SQL Tutorial","description":"An Interactive SQL Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqltutorial.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/pages\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/comments?post=90"}],"version-history":[{"count":0,"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/pages\/90\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/media?parent=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}