{"id":1246,"date":"2010-01-24T01:29:22","date_gmt":"2010-01-24T09:29:22","guid":{"rendered":"http:\/\/www.mysqltutorial.org\/?page_id=1246"},"modified":"2023-12-31T03:05:15","modified_gmt":"2023-12-31T10:05:15","slug":"mysql-where","status":"publish","type":"page","link":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/","title":{"rendered":"MySQL WHERE"},"content":{"rendered":"\n<p><strong>Summary: <\/strong>in this tutorial,&nbsp;you will learn how to use the MySQL <code>WHERE<\/code> clause in the <code>SELECT<\/code> statement to filter rows from the result set.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to MySQL WHERE clause<\/h2>\n\n\n\n<p>The <code>WHERE<\/code> clause allows you to specify a search condition for the rows returned by a query. The following shows the syntax of the <code>WHERE<\/code> clause:<\/p>\n\n\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> \n    select_list\n<span class=\"hljs-keyword\">FROM<\/span>\n    table_name\n<span class=\"hljs-keyword\">WHERE<\/span>\n    search_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>\n\n\n<p>The <code>search_condition<\/code> is a combination of one or more expressions using the logical operator <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-and\/\">AND<\/a><\/code>, <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-or\/\">OR<\/a><\/code> and <code>NOT<\/code>.<\/p>\n\n\n\n<p>In MySQL, a predicate is a <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-boolean\/\">Boolean<\/a> expression that evaluates to <code>TRUE<\/code>, <code>FALSE<\/code>, or <code>UNKNOWN<\/code>.<\/p>\n\n\n\n<p>The <code>SELECT<\/code> statement will include any row that satisfies the <code>search_condition<\/code> in the result set.<\/p>\n\n\n\n<p>Besides the <code>SELECT<\/code> statement, you can use the <code>WHERE<\/code> clause in the <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-update\/\">UPDATE<\/a><\/code> or <a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-delete\/\"><code>DELETE<\/code><\/a> statement to specify which rows to update or delete.<\/p>\n\n\n\n<p>When executing a <code>SELECT<\/code> statement with a <code>WHERE<\/code> clause, MySQL evaluates the <code>WHERE<\/code> clause after the <code>FROM<\/code> clause and before the <code>SELECT<\/code> and <code>ORDER BY<\/code> clauses:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2023\/10\/MySQL-WHERE.svg\" alt=\"MySQL WHERE\" class=\"wp-image-10801\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">MySQL WHERE clause examples<\/h2>\n\n\n\n<p>We&#8217;ll use the <code>employees<\/code> table from the <a href=\"https:\/\/www.mysqltutorial.org\/getting-started-with-mysql\/mysql-sample-database\/\">sample database<\/a> for the demonstration:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2023\/10\/employees.svg\" alt=\"\" class=\"wp-image-10759\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">1) Using the WHERE clause with equality operator example<\/h3>\n\n\n\n<p>The following query uses the <code>WHERE<\/code> clause to find all employees whose job titles are <code>Sales Rep<\/code>:<\/p>\n\n\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\"><span class=\"hljs-keyword\">SELECT<\/span> \n    lastname, \n    firstname, \n    jobtitle\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n<span class=\"hljs-keyword\">WHERE<\/span>\n    jobtitle = <span class=\"hljs-string\">'Sales Rep'<\/span>;<\/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>\n\n\n<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-where\/#1\" target=\"_blank\" rel=\"noopener noreferrer\">Try It Out<\/a><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">+-----------+-----------+-----------+\n| lastname  | firstname | jobtitle  |\n+-----------+-----------+-----------+\n| Jennings  | Leslie    | Sales Rep |\n| Thompson  | Leslie    | Sales Rep |\n| Firrelli  | Julie     | Sales Rep |\n| Patterson | Steve     | Sales Rep |\n| Tseng     | Foon Yue  | Sales Rep |\n| Vanauf    | George    | Sales Rep |\n| Bondur    | Loui      | Sales Rep |\n| Hernandez | Gerard    | Sales Rep |\n| Castillo  | Pamela    | Sales Rep |\n| Bott      | Larry     | Sales Rep |\n| Jones     | Barry     | Sales Rep |\n| Fixter    | Andy      | Sales Rep |\n| Marsh     | Peter     | Sales Rep |\n| King      | Tom       | Sales Rep |\n| Nishi     | Mami      | Sales Rep |\n| Kato      | Yoshimi   | Sales Rep |\n| Gerard    | Martin    | Sales Rep |\n+-----------+-----------+-----------+\n17 rows in set (0.00 sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><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>\n\n\n<p>In this example, the <code>SELECT<\/code> statement examines all rows of the <code>employees<\/code> table and selects only rows whose values are in the <code>jobTitle<\/code> column are <code>Sales Rep<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2) Using the WHERE clause with the AND operator<\/h3>\n\n\n\n<p>The following example uses the <code>WHERE<\/code> clause to find employees whose job titles are <code>Sales Rep<\/code> and office codes are 1:<\/p>\n\n\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> \n    lastname, \n    firstname, \n    jobtitle,\n    officeCode\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n<span class=\"hljs-keyword\">WHERE<\/span>\n    jobtitle = <span class=\"hljs-string\">'Sales Rep'<\/span> <span class=\"hljs-keyword\">AND<\/span> \n    officeCode = <span class=\"hljs-number\">1<\/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>\n\n\n<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-where\/#2\" target=\"_blank\" rel=\"noopener noreferrer\">Try It Out<\/a><\/p>\n\n\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\">+----------+-----------+-----------+------------+\n| lastname | firstname | jobtitle  | officeCode |\n+----------+-----------+-----------+------------+\n| Jennings | Leslie    | Sales Rep | 1          |\n| Thompson | Leslie    | Sales Rep | 1          |\n+----------+-----------+-----------+------------+\n2 rows in set (0.00 sec)<\/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>\n\n\n<p>In this example, the expression in the <code>WHERE<\/code> clause uses the <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-and\/\">AND<\/a><\/code> operator to combine two conditions:<\/p>\n\n\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\">jobtitle = 'Sales Rep' AND officeCode = 1;<\/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>\n\n\n<p>The <code>AND<\/code> operator evaluates to <code>TRUE<\/code> only if both expressions are evaluated to <code>TRUE<\/code>. Therefore, the query returns rows whose values in the <code>jobTitle<\/code> column is <code>Sales Rep<\/code> and <code>officeCode<\/code> is 1.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3) Using MySQL WHERE clause with OR operator<\/h3>\n\n\n\n<p>This query finds employees whose job title is <code>Sales Rep<\/code> or employees who locate the office with office code 1:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" 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> \n    lastName, \n    firstName, \n    jobTitle, \n    officeCode\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n<span class=\"hljs-keyword\">WHERE<\/span>\n    jobtitle = <span class=\"hljs-string\">'Sales Rep'<\/span> <span class=\"hljs-keyword\">OR<\/span> \n    officeCode = <span class=\"hljs-number\">1<\/span>\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> \n    officeCode , \n    jobTitle;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><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>\n\n\n<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-where\/#3\" target=\"_blank\" rel=\"noopener noreferrer\">Try It Out<\/a><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">+-----------+-----------+--------------------+------------+\n| lastName  | firstName | jobTitle           | officeCode |\n+-----------+-----------+--------------------+------------+\n| Murphy    | Diane     | President          | 1          |\n| Bow       | Anthony   | Sales Manager (NA) | 1          |\n| Jennings  | Leslie    | Sales Rep          | 1          |\n| Thompson  | Leslie    | Sales Rep          | 1          |\n| Firrelli  | Jeff      | VP Marketing       | 1          |\n| Patterson | Mary      | VP Sales           | 1          |\n| Firrelli  | Julie     | Sales Rep          | 2          |\n| Patterson | Steve     | Sales Rep          | 2          |\n| Tseng     | Foon Yue  | Sales Rep          | 3          |\n| Vanauf    | George    | Sales Rep          | 3          |\n| Bondur    | Loui      | Sales Rep          | 4          |\n| Hernandez | Gerard    | Sales Rep          | 4          |\n| Castillo  | Pamela    | Sales Rep          | 4          |\n| Gerard    | Martin    | Sales Rep          | 4          |\n| Nishi     | Mami      | Sales Rep          | 5          |\n| Kato      | Yoshimi   | Sales Rep          | 5          |\n| Fixter    | Andy      | Sales Rep          | 6          |\n| Marsh     | Peter     | Sales Rep          | 6          |\n| King      | Tom       | Sales Rep          | 6          |\n| Bott      | Larry     | Sales Rep          | 7          |\n| Jones     | Barry     | Sales Rep          | 7          |\n+-----------+-----------+--------------------+------------+\n21 rows in set (0.00 sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><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>\n\n\n<p>The <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-or\/\">OR<\/a><\/code> operator evaluates to <code>TRUE<\/code> only if one of the expressions evaluates to <code>TRUE<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">jobtitle = 'Sales Rep' OR officeCode = 1<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><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>\n\n\n<p>Therefore, the query returns any employee who has the job title Sales Rep or office code 1.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4) Using the WHERE clause with the BETWEEN operator example<\/h3>\n\n\n\n<p>The <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-between\">BETWEEN<\/a><\/code> operator returns <code>TRUE<\/code> if a value is in a range of values:<\/p>\n\n\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\">expression BETWEEN low AND high<\/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>\n\n\n<p>The following query finds employees who are located in offices whose office code is from 1 to 3:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" 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> \n    firstName, \n    lastName, \n    officeCode\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n<span class=\"hljs-keyword\">WHERE<\/span>\n    officeCode <span class=\"hljs-keyword\">BETWEEN<\/span> <span class=\"hljs-number\">1<\/span> <span class=\"hljs-keyword\">AND<\/span> <span class=\"hljs-number\">3<\/span>\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> officeCode;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><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>\n\n\n<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-where\/#4\" target=\"_blank\" rel=\"noopener noreferrer\">Try It Out<\/a><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">+-----------+-----------+------------+\n| firstName | lastName  | officeCode |\n+-----------+-----------+------------+\n| Diane     | Murphy    | 1          |\n| Mary      | Patterson | 1          |\n| Jeff      | Firrelli  | 1          |\n| Anthony   | Bow       | 1          |\n| Leslie    | Jennings  | 1          |\n| Leslie    | Thompson  | 1          |\n| Julie     | Firrelli  | 2          |\n| Steve     | Patterson | 2          |\n| Foon Yue  | Tseng     | 3          |\n| George    | Vanauf    | 3          |\n+-----------+-----------+------------+\n10 rows in set (0.00 sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><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>\n\n\n<h3 class=\"wp-block-heading\">5) Using the WHERE clause with the LIKE operator example<\/h3>\n\n\n\n<p>The <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-like\/\">LIKE<\/a><\/code> operator evaluates to <code>TRUE<\/code> if a value matches a specified pattern. <\/p>\n\n\n\n<p>To form a pattern, you use the <code>%<\/code> and <code>_<\/code> wildcards. The <code>%<\/code> wildcard matches any string of zero or more characters while the <code>_<\/code> wildcard matches any single character.<\/p>\n\n\n\n<p>The  following query finds the employees whose last names end with the string <code>'son'<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" 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> \n    firstName, \n    lastName\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n<span class=\"hljs-keyword\">WHERE<\/span>\n    lastName <span class=\"hljs-keyword\">LIKE<\/span> <span class=\"hljs-string\">'%son'<\/span>\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> firstName;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><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>\n\n\n<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-where\/#5\" target=\"_blank\" rel=\"noopener noreferrer\">Try It Out<\/a><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">+-----------+-----------+\n| firstName | lastName  |\n+-----------+-----------+\n| Leslie    | Thompson  |\n| Mary      | Patterson |\n| Steve     | Patterson |\n| William   | Patterson |\n+-----------+-----------+\n4 rows in set (0.00 sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><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>\n\n\n<h3 class=\"wp-block-heading\">6) Using the WHERE clause with the IN operator example<\/h3>\n\n\n\n<p>The <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-in\/\">IN<\/a><\/code> operator returns <code>TRUE<\/code> if a value matches any value in a list.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">value IN (value1, value2,...)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><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>\n\n\n<p>The following example uses the <code>WHERE<\/code> clause with the <code>IN<\/code> operator to find employees who are located in the offices with the codes 1, 2, and 3:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-16\" 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> \n    firstName, \n    lastName, \n    officeCode\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n<span class=\"hljs-keyword\">WHERE<\/span>\n    officeCode <span class=\"hljs-keyword\">IN<\/span> (<span class=\"hljs-number\">1<\/span> , <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>)\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> \n    officeCode;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-16\"><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>\n\n\n<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-where\/#6\" target=\"_blank\" rel=\"noopener noreferrer\">Try It Out<\/a><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-17\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">+-----------+-----------+------------+\n| firstName | lastName  | officeCode |\n+-----------+-----------+------------+\n| Diane     | Murphy    | 1          |\n| Mary      | Patterson | 1          |\n| Jeff      | Firrelli  | 1          |\n| Anthony   | Bow       | 1          |\n| Leslie    | Jennings  | 1          |\n| Leslie    | Thompson  | 1          |\n| Julie     | Firrelli  | 2          |\n| Steve     | Patterson | 2          |\n| Foon Yue  | Tseng     | 3          |\n| George    | Vanauf    | 3          |\n+-----------+-----------+------------+\n10 rows in set (0.00 sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-17\"><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>\n\n\n<h3 class=\"wp-block-heading\">7) Using MySQL WHERE clause with the IS NULL operator<\/h3>\n\n\n\n<p>To check if a value is <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-null\/\">NULL<\/a><\/code> or not, you use the <code><a href=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-is-null\/\">IS NULL<\/a><\/code> operator, not the equal operator (<code>=<\/code>). The <code>IS NULL<\/code> operator returns <code>TRUE<\/code> if a value is <code>NULL<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-18\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">value IS NULL<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-18\"><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>\n\n\n<p class=\"note\">In the database world, <code>NULL<\/code> is a marker that indicates that a value is missing or unknown. NULL is not equivalent to the number 0 or an empty string.<\/p>\n\n\n\n<p>The following statement uses the <code>WHERE<\/code> clause with the <code>IS NULL<\/code> operator to get the rows with the values in the <code>reportsTo<\/code> column are <code>NULL<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-19\" 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> \n    lastName, \n    firstName, \n    reportsTo\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n<span class=\"hljs-keyword\">WHERE<\/span>\n    reportsTo <span class=\"hljs-keyword\">IS<\/span> <span class=\"hljs-literal\">NULL<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-19\"><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>\n\n\n<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-where\/#7\" target=\"_blank\" rel=\"noopener noreferrer\">Try It Out<\/a><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-20\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">+----------+-----------+-----------+\n| lastName | firstName | reportsTo |\n+----------+-----------+-----------+\n| Murphy   | Diane     |      NULL |\n+----------+-----------+-----------+\n1 row in set (0.01 sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-20\"><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>\n\n\n<h3 class=\"wp-block-heading\">8) Using MySQL WHERE clause with comparison operators<\/h3>\n\n\n\n<p>The following table shows the comparison operators that you can use to form the expression in the <code>WHERE<\/code> clause.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Operator<\/th><th>Description<\/th><\/tr><tr><td>=<\/td><td>Equal to. You can use it with almost any data type.<\/td><\/tr><tr><td>&lt;&gt; or !=<\/td><td>Not equal to<\/td><\/tr><tr><td>&lt;<\/td><td>Less than. You typically use it with numeric and date\/time data types.<\/td><\/tr><tr><td>&gt;<\/td><td>Greater than.<\/td><\/tr><tr><td>&lt;=<\/td><td>Less than or equal to<\/td><\/tr><tr><td>&gt;=<\/td><td>Greater than or equal to<\/td><\/tr><\/thead><\/table><\/figure>\n\n\n\n<p>The following query uses the not equal to (&lt;&gt;) operator to find all employees who are not the <code>Sales Rep<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-21\" 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> \n    lastname, \n    firstname, \n    jobtitle\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n<span class=\"hljs-keyword\">WHERE<\/span>\n    jobtitle &lt;&gt; <span class=\"hljs-string\">'Sales Rep'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-21\"><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>\n\n\n<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-where\/#8\" target=\"_blank\" rel=\"noopener noreferrer\">Try It Out<\/a><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-22\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">+-----------+-----------+----------------------+\n| lastname  | firstname | jobtitle             |\n+-----------+-----------+----------------------+\n| Murphy    | Diane     | President            |\n| Patterson | Mary      | VP Sales             |\n| Firrelli  | Jeff      | VP Marketing         |\n| Patterson | William   | Sales Manager (APAC) |\n| Bondur    | Gerard    | Sale Manager (EMEA)  |\n| Bow       | Anthony   | Sales Manager (NA)   |\n+-----------+-----------+----------------------+\n6 rows in set (0.00 sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-22\"><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>\n\n\n<p>The following query finds employees whose office code is greater than 5:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-23\" 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> \n    lastname, \n    firstname, \n    officeCode\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n<span class=\"hljs-keyword\">WHERE<\/span> \n    officecode &gt; <span class=\"hljs-number\">5<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-23\"><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>\n\n\n<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-where\/#9\" target=\"_blank\" rel=\"noopener noreferrer\">Try It Out<\/a><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-24\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">+-----------+-----------+------------+\n| lastname  | firstname | officeCode |\n+-----------+-----------+------------+\n| Patterson | William   | 6          |\n| Bott      | Larry     | 7          |\n| Jones     | Barry     | 7          |\n| Fixter    | Andy      | 6          |\n| Marsh     | Peter     | 6          |\n| King      | Tom       | 6          |\n+-----------+-----------+------------+\n6 rows in set (0.00 sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-24\"><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>\n\n\n<p>The following query returns employees with office code less than or equal to 4&nbsp;(&lt;=4):<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-25\" 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> \n    lastname, \n    firstname, \n    officeCode\n<span class=\"hljs-keyword\">FROM<\/span>\n    employees\n<span class=\"hljs-keyword\">WHERE<\/span> \n    officecode &lt;= <span class=\"hljs-number\">4<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-25\"><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>\n\n\n<p><a class=\"sql\" href=\"https:\/\/www.mysqltutorial.org\/tryit\/query\/mysql-where\/#10\" target=\"_blank\" rel=\"noopener noreferrer\">Try It Out<\/a><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-26\" data-shcb-language-name=\"plaintext\" data-shcb-language-slug=\"plaintext\"><span><code class=\"hljs language-plaintext\">+-----------+-----------+------------+\n| lastname  | firstname | officeCode |\n+-----------+-----------+------------+\n| Murphy    | Diane     | 1          |\n| Patterson | Mary      | 1          |\n| Firrelli  | Jeff      | 1          |\n| Bondur    | Gerard    | 4          |\n| Bow       | Anthony   | 1          |\n| Jennings  | Leslie    | 1          |\n| Thompson  | Leslie    | 1          |\n| Firrelli  | Julie     | 2          |\n| Patterson | Steve     | 2          |\n| Tseng     | Foon Yue  | 3          |\n| Vanauf    | George    | 3          |\n| Bondur    | Loui      | 4          |\n| Hernandez | Gerard    | 4          |\n| Castillo  | Pamela    | 4          |\n| Gerard    | Martin    | 4          |\n+-----------+-----------+------------+\n15 rows in set (0.00 sec)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-26\"><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>\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the <code>WHERE<\/code> clause to filter rows by a condition.<\/li>\n\n\n\n<li>MySQL evaluates the <code>WHERE<\/code> clause after the <code>FROM<\/code> clause and before the <code>SELECT<\/code> and <code>ORDER BY<\/code> clauses.<\/li>\n<\/ul>\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=\"1246\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/\"\n\t\t\t\tdata-post-title=\"MySQL 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=\"1246\"\n\t\t\t\tdata-post-url=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/\"\n\t\t\t\tdata-post-title=\"MySQL 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 MySQL WHERE clause to filter rows based on specified conditions.<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":174,"menu_order":3,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-1246","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MySQL WHERE<\/title>\n<meta name=\"description\" content=\"This tutorial shows you how to use MySQL WHERE clause to filter rows based on specified 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.mysqltutorial.org\/mysql-basics\/mysql-where\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL WHERE\" \/>\n<meta property=\"og:description\" content=\"This tutorial shows you how to use MySQL WHERE clause to filter rows based on specified conditions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/\" \/>\n<meta property=\"og:site_name\" content=\"MySQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-31T10:05:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2023\/10\/MySQL-WHERE.svg\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-where\\\/\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-where\\\/\",\"name\":\"MySQL WHERE\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-where\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-where\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/MySQL-WHERE.svg\",\"datePublished\":\"2010-01-24T09:29:22+00:00\",\"dateModified\":\"2023-12-31T10:05:15+00:00\",\"description\":\"This tutorial shows you how to use MySQL WHERE clause to filter rows based on specified conditions.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-where\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-where\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-where\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/MySQL-WHERE.svg\",\"contentUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/MySQL-WHERE.svg\",\"caption\":\"MySQL WHERE\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/mysql-where\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL Basics\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-basics\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"MySQL WHERE\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\",\"name\":\"MySQL Tutorial\",\"description\":\"A comprehensive MySQL Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mysqltutorial.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":"MySQL WHERE","description":"This tutorial shows you how to use MySQL WHERE clause to filter rows based on specified 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.mysqltutorial.org\/mysql-basics\/mysql-where\/","og_locale":"en_US","og_type":"article","og_title":"MySQL WHERE","og_description":"This tutorial shows you how to use MySQL WHERE clause to filter rows based on specified conditions.","og_url":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/","og_site_name":"MySQL Tutorial","article_modified_time":"2023-12-31T10:05:15+00:00","og_image":[{"url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2023\/10\/MySQL-WHERE.svg","type":"","width":"","height":""}],"twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/","url":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/","name":"MySQL WHERE","isPartOf":{"@id":"https:\/\/www.mysqltutorial.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/#primaryimage"},"image":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2023\/10\/MySQL-WHERE.svg","datePublished":"2010-01-24T09:29:22+00:00","dateModified":"2023-12-31T10:05:15+00:00","description":"This tutorial shows you how to use MySQL WHERE clause to filter rows based on specified conditions.","breadcrumb":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/#primaryimage","url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2023\/10\/MySQL-WHERE.svg","contentUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2023\/10\/MySQL-WHERE.svg","caption":"MySQL WHERE"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mysqltutorial.org\/mysql-basics\/mysql-where\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.mysqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"MySQL Basics","item":"https:\/\/www.mysqltutorial.org\/mysql-basics\/"},{"@type":"ListItem","position":3,"name":"MySQL WHERE"}]},{"@type":"WebSite","@id":"https:\/\/www.mysqltutorial.org\/#website","url":"https:\/\/www.mysqltutorial.org\/","name":"MySQL Tutorial","description":"A comprehensive MySQL Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mysqltutorial.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/1246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/comments?post=1246"}],"version-history":[{"count":5,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/1246\/revisions"}],"predecessor-version":[{"id":13947,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/1246\/revisions\/13947"}],"up":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/174"}],"wp:attachment":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/media?parent=1246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}