{"id":130387,"date":"2022-04-13T18:00:12","date_gmt":"2022-04-13T22:00:12","guid":{"rendered":"https:\/\/brainstation.io\/?post_type=codex-reference&#038;p=130387"},"modified":"2025-02-04T14:34:16","modified_gmt":"2025-02-04T19:34:16","slug":"where","status":"publish","type":"codex-reference","link":"https:\/\/brainstation.io\/learn\/sql\/where","title":{"rendered":"Where"},"content":{"rendered":"\n<header class=\"wp-block-bstn-blocks-hero-simple bstn-blocks-hero-simple\"><div class=\"bstn-blocks-hero-simple__full-width-wrapper bstn-blocks-hero-simple__full-width-wrapper--main bstn-blocks-hero-simple__full-width-wrapper--bg-flair\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" fill=\"none\" viewBox=\"0 0 1140 621\" class=\"bstn-blocks-hero-simple__bg-flair--rich\"><g opacity=\"0.55\"><path stroke=\"currentColor\" stroke-linecap=\"square\" d=\"M60.026 736.434V203.02\"><\/path><path stroke=\"currentColor\" stroke-linecap=\"square\" d=\"M60.364 436.132-120 436.131zm0-99.873H-120zm0-99.872H-120zM128 536.004h-248z\" clip-rule=\"evenodd\"><\/path><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M57.518 535.982a2.286 2.286 0 1 1 4.572 0 2.286 2.286 0 0 1-4.572 0m0-99.836a2.286 2.286 0 1 1 4.572-.002 2.286 2.286 0 0 1-4.572.002m0-99.837a2.286 2.286 0 1 1 4.572-.002 2.286 2.286 0 0 1-4.572.002m0-99.837a2.286 2.286 0 1 1 4.572-.002 2.286 2.286 0 0 1-4.572.002\" clip-rule=\"evenodd\"><\/path><\/g><g opacity=\"0.55\"><path stroke=\"currentColor\" stroke-linecap=\"square\" d=\"M979.195-28.206V397.98m81.185-524.745V397.98\"><\/path><path stroke=\"currentColor\" stroke-linecap=\"square\" d=\"M1141.45 168.46H964zm0 98.334H964zm0 98.333H964zm66.55-295H964z\" clip-rule=\"evenodd\"><\/path><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M1138.66 70.148a2.244 2.244 0 1 0 4.49 0 2.246 2.246 0 1 0-4.49-.001zm-80.21 0c0 1.243 1.01 2.251 2.25 2.251s2.25-1.008 2.25-2.251-1.01-2.251-2.25-2.251-2.25 1.008-2.25 2.25zm-81.707 0a2.25 2.25 0 1 0 4.5.004 2.25 2.25 0 0 0-4.5-.005zm81.707 98.299a2.25 2.25 0 0 0 2.25 2.251 2.252 2.252 0 0 0 0-4.503 2.253 2.253 0 0 0-2.25 2.252m-81.707 0a2.25 2.25 0 1 0 4.498 0 2.25 2.25 0 0 0-2.249-2.252 2.25 2.25 0 0 0-2.249 2.252m161.917-.001a2.244 2.244 0 1 0 4.49 0 2.246 2.246 0 1 0-4.49 0m0 98.299a2.244 2.244 0 1 0 4.49 0 2.246 2.246 0 1 0-4.49 0m-80.21 0c0 1.243 1.01 2.251 2.25 2.251s2.25-1.008 2.25-2.251-1.01-2.251-2.25-2.251-2.25 1.008-2.25 2.251m-81.707 0a2.25 2.25 0 1 0 4.5.002 2.25 2.25 0 0 0-4.5-.002m81.707 98.299c0 1.243 1.01 2.251 2.25 2.251s2.25-1.008 2.25-2.251-1.01-2.251-2.25-2.251-2.25 1.008-2.25 2.251m-81.707 0a2.25 2.25 0 1 0 4.5.002 2.25 2.25 0 0 0-4.5-.002m161.917 0a2.244 2.244 0 1 0 4.49 0 2.246 2.246 0 1 0-4.49 0\" clip-rule=\"evenodd\"><\/path><\/g><\/svg><div class=\"bstn-blocks-hero-simple__container\"><div class=\"bstn-blocks-hero-simple__copy-container\"><div class=\"bstn-blocks-hero-simple__subtitle-wrapper\"><p class=\"bstn-blocks-hero-simple__subtitle\">SQL tutorial<\/p><\/div><h1 class=\"bstn-blocks-hero-simple__title\">SQL Where<\/h1><p class=\"bstn-blocks-hero-simple__description\"><meta charset=\"utf-8\">Learn more about SQL, a standard language for interacting with databases and storing, manipulating, and retrieving data from databases.<br><br><a rel=\"noreferrer noopener\" href=\"https:\/\/brainstation.io\/learn\/sql\/\" target=\"_blank\">Go hands-on with SQL in our free interactive SQL tutorial.<\/a><\/p><\/div><div class=\"bstn-blocks-hero-simple__image-container\"><\/div><\/div><\/div><\/header>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-1 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:66.66%\">\n<p class=\"is-style-bstn-paragraph-documentation-body\">The SQL <code>WHERE<\/code> clause is used to alter the behavior of a <code>SELECT<\/code> statement or other SQL commands that are applied to rows of data, in order to either restrict the rows returned by a query or the records affected by other statement types (<code>DELETE<\/code>, <code>UPDATE<\/code>, etc.) The SQL WHERE clause is the simplest clause to understand and without question one of the most frequently used.<\/p>\n\n\n\n<p class=\"is-style-bstn-paragraph-documentation-body\">Let\u2019s return to looking at the employees table. In the previous section, we used a <code>SELECT<\/code> statement to return all rows from the table, as below:<\/p>\n\n\n\n<div class=\"wp-block-bstn-blocks-code-snippet bstn-blocks-code-snippet\" data-code-snippet=\"true\"><div class=\"bstn-blocks-code-snippet__title-bar\"><span class=\"bstn-blocks-code-snippet__title\">Code Example<\/span><button class=\"bstn-blocks-code-snippet__copy-trigger\" data-copy-to-clipboard=\"true\"><svg viewbox=\"0 0 12 13\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"bstn-blocks-code-snippet__copy-trigger-icon\"><path d=\"M10.875.5h-7.5c-.633 0-1.125.516-1.125 1.125V2.75H1.125C.492 2.75 0 3.266 0 3.875v7.5A1.11 1.11 0 001.125 12.5h7.5c.61 0 1.125-.492 1.125-1.125V10.25h1.125c.61 0 1.125-.492 1.125-1.125v-7.5A1.14 1.14 0 0010.875.5zm-2.39 10.875h-7.22c-.093 0-.14-.047-.14-.14v-7.22c0-.07.047-.14.14-.14h.985v5.25a1.11 1.11 0 001.125 1.125h5.25v.984c0 .094-.07.141-.14.141zm2.25-2.25h-7.22c-.093 0-.14-.047-.14-.14v-7.22c0-.07.047-.14.14-.14h7.22c.07 0 .14.07.14.14v7.22c0 .093-.07.14-.14.14z\" fill=\"currentColor\"><\/path><\/svg><span data-copy-to-clipboard-text=\"true\">Copy<\/span><\/button><\/div><pre class=\"bstn-blocks-code-snippet__code-snippet-area match-braces line-numbers language-sql\" data-language=\"sql\"><code>SELECT * FROM employees;<\/code><\/pre><\/div>\n\n\n\n<p class=\"is-style-bstn-paragraph-documentation-body\">However, this returns all rows from the table &#8211; and could be a very large result, as some databases have tables with millions (or even hundreds of millions!) of records. Furthermore, we would like to \u201cdrill-down\u201d and look for more specific employees within the <code>employees<\/code> table matching specific criteria.&nbsp;<\/p>\n\n\n\n<p class=\"is-style-bstn-paragraph-documentation-body\">So we will apply a <code>WHERE<\/code> clause here to alter the behavior of the <code>SELECT<\/code> statement. A <code>WHERE<\/code> clause comes after the <code>SELECT<\/code> statement and takes a form as below:<\/p>\n\n\n\n<div class=\"wp-block-bstn-blocks-code-snippet bstn-blocks-code-snippet\" data-code-snippet=\"true\"><div class=\"bstn-blocks-code-snippet__title-bar\"><span class=\"bstn-blocks-code-snippet__title\">Code Example<\/span><button class=\"bstn-blocks-code-snippet__copy-trigger\" data-copy-to-clipboard=\"true\"><svg viewbox=\"0 0 12 13\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"bstn-blocks-code-snippet__copy-trigger-icon\"><path d=\"M10.875.5h-7.5c-.633 0-1.125.516-1.125 1.125V2.75H1.125C.492 2.75 0 3.266 0 3.875v7.5A1.11 1.11 0 001.125 12.5h7.5c.61 0 1.125-.492 1.125-1.125V10.25h1.125c.61 0 1.125-.492 1.125-1.125v-7.5A1.14 1.14 0 0010.875.5zm-2.39 10.875h-7.22c-.093 0-.14-.047-.14-.14v-7.22c0-.07.047-.14.14-.14h.985v5.25a1.11 1.11 0 001.125 1.125h5.25v.984c0 .094-.07.141-.14.141zm2.25-2.25h-7.22c-.093 0-.14-.047-.14-.14v-7.22c0-.07.047-.14.14-.14h7.22c.07 0 .14.07.14.14v7.22c0 .093-.07.14-.14.14z\" fill=\"currentColor\"><\/path><\/svg><span data-copy-to-clipboard-text=\"true\">Copy<\/span><\/button><\/div><pre class=\"bstn-blocks-code-snippet__code-snippet-area match-braces line-numbers language-sql\" data-language=\"sql\"><code>SELECT &lt;columns> FROM &lt;table> WHERE &lt;condition>;<\/code><\/pre><\/div>\n\n\n\n<p class=\"is-style-bstn-paragraph-documentation-body\">Where, in this form, <code>&lt;condition&gt;<\/code> must be a SQL <em>expression<\/em> which evaluates to either <code>True<\/code> or <code>False<\/code> for each record in the table &#8211; that is, a <em>predicate<\/em>.<\/p>\n\n\n\n<p class=\"is-style-bstn-paragraph-documentation-body\">The simplest expression we can write is to check whether a given column is equal to a value we specify using the equality operator (=). This will act as a filter and return only the rows which match the predicate we have written.<\/p>\n\n\n\n<p class=\"is-style-bstn-paragraph-documentation-body\">For example, let\u2019s look at the employees table again, but only return employees with the first name \u2018Georgi\u2019:<\/p>\n\n\n\n<div class=\"wp-block-bstn-blocks-code-snippet bstn-blocks-code-snippet\" data-code-snippet=\"true\"><div class=\"bstn-blocks-code-snippet__title-bar\"><span class=\"bstn-blocks-code-snippet__title\">Code Example<\/span><button class=\"bstn-blocks-code-snippet__copy-trigger\" data-copy-to-clipboard=\"true\"><svg viewbox=\"0 0 12 13\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"bstn-blocks-code-snippet__copy-trigger-icon\"><path d=\"M10.875.5h-7.5c-.633 0-1.125.516-1.125 1.125V2.75H1.125C.492 2.75 0 3.266 0 3.875v7.5A1.11 1.11 0 001.125 12.5h7.5c.61 0 1.125-.492 1.125-1.125V10.25h1.125c.61 0 1.125-.492 1.125-1.125v-7.5A1.14 1.14 0 0010.875.5zm-2.39 10.875h-7.22c-.093 0-.14-.047-.14-.14v-7.22c0-.07.047-.14.14-.14h.985v5.25a1.11 1.11 0 001.125 1.125h5.25v.984c0 .094-.07.141-.14.141zm2.25-2.25h-7.22c-.093 0-.14-.047-.14-.14v-7.22c0-.07.047-.14.14-.14h7.22c.07 0 .14.07.14.14v7.22c0 .093-.07.14-.14.14z\" fill=\"currentColor\"><\/path><\/svg><span data-copy-to-clipboard-text=\"true\">Copy<\/span><\/button><\/div><pre class=\"bstn-blocks-code-snippet__code-snippet-area match-braces line-numbers language-sql\" data-language=\"sql\"><code>SELECT * FROM employees WHERE first_name = \"Georgi\";<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>emp_no<\/strong><\/td><td><strong>birth_date<\/strong><\/td><td><strong>first_name<\/strong><\/td><td><strong>last_name<\/strong><\/td><td><strong>gender<\/strong><\/td><td><strong>hire_date<\/strong><\/td><\/tr><tr><td>10001<\/td><td>1953-09-02<\/td><td>Georgi<\/td><td>Facello<\/td><td>M<\/td><td>1986-06-26<\/td><\/tr><tr><td>10909<\/td><td>1954-11-11<\/td><td>Georgi<\/td><td>Atchley<\/td><td>M<\/td><td>1985-04-21<\/td><\/tr><tr><td>11029<\/td><td>1962-07-12<\/td><td>Georgi<\/td><td>Itzfeldt<\/td><td>M<\/td><td>1992-12-27<\/td><\/tr><tr><td>11430<\/td><td>1957-01-23<\/td><td>Georgi<\/td><td>Klassen<\/td><td>M<\/td><td>1996-02-27<\/td><\/tr><tr><td>12157<\/td><td>1960-03-30<\/td><td>Georgi<\/td><td>Barinka<\/td><td>M<\/td><td>1985-06-04<\/td><\/tr><tr><td>\u2026<\/td><td>\u2026<\/td><td>\u2026<\/td><td>\u2026<\/td><td>\u2026<\/td><td>\u2026<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"is-style-bstn-paragraph-documentation-body\">We can see above that our SQL query modified with a <code>WHERE<\/code> clause has only returned rows matching the predicate, and filtered the result set that is returned from the table specified.<\/p>\n\n\n\n<p class=\"is-style-bstn-paragraph-documentation-body\">Predicates need not be specified using only the equality operator nor using only text fields; we could also look for rows in the <code>employees<\/code> table where the hire date is greater than a certain value, using the greater than operator (&gt;) and a date value:<\/p>\n\n\n\n<div class=\"wp-block-bstn-blocks-code-snippet bstn-blocks-code-snippet\" data-code-snippet=\"true\"><div class=\"bstn-blocks-code-snippet__title-bar\"><span class=\"bstn-blocks-code-snippet__title\">Code Example<\/span><button class=\"bstn-blocks-code-snippet__copy-trigger\" data-copy-to-clipboard=\"true\"><svg viewbox=\"0 0 12 13\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"bstn-blocks-code-snippet__copy-trigger-icon\"><path d=\"M10.875.5h-7.5c-.633 0-1.125.516-1.125 1.125V2.75H1.125C.492 2.75 0 3.266 0 3.875v7.5A1.11 1.11 0 001.125 12.5h7.5c.61 0 1.125-.492 1.125-1.125V10.25h1.125c.61 0 1.125-.492 1.125-1.125v-7.5A1.14 1.14 0 0010.875.5zm-2.39 10.875h-7.22c-.093 0-.14-.047-.14-.14v-7.22c0-.07.047-.14.14-.14h.985v5.25a1.11 1.11 0 001.125 1.125h5.25v.984c0 .094-.07.141-.14.141zm2.25-2.25h-7.22c-.093 0-.14-.047-.14-.14v-7.22c0-.07.047-.14.14-.14h7.22c.07 0 .14.07.14.14v7.22c0 .093-.07.14-.14.14z\" fill=\"currentColor\"><\/path><\/svg><span data-copy-to-clipboard-text=\"true\">Copy<\/span><\/button><\/div><pre class=\"bstn-blocks-code-snippet__code-snippet-area match-braces line-numbers language-sql\" data-language=\"sql\"><code>SELECT * FROM employees WHERE hire_date > \"1995-01-01\";<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>emp_no<\/strong><\/td><td><strong>birth_date<\/strong><\/td><td><strong>first_name<\/strong><\/td><td><strong>last_name<\/strong><\/td><td><strong>gender<\/strong><\/td><td><strong>hire_date<\/strong><\/td><\/tr><tr><td>10016<\/td><td>1961-05-02<\/td><td>Kazuhito<\/td><td>Cappelletti<\/td><td>M<\/td><td>1995-01-27<\/td><\/tr><tr><td>10019<\/td><td>1953-01-23<\/td><td>Lillian<\/td><td>Haddadi<\/td><td>M<\/td><td>1999-04-30<\/td><\/tr><tr><td>10022<\/td><td>1952-07-08<\/td><td>Shahaf<\/td><td>Famili<\/td><td>M<\/td><td>1995-08-22<\/td><\/tr><tr><td>10024<\/td><td>1958-09-05<\/td><td>Suzette<\/td><td>Pettey<\/td><td>F<\/td><td>1997-05-19<\/td><\/tr><tr><td>10026<\/td><td>1953-04-03<\/td><td>Yongqiao<\/td><td>Berztiss<\/td><td>M<\/td><td>1995-03-20<\/td><\/tr><tr><td>\u2026<\/td><td>\u2026<\/td><td>\u2026<\/td><td>\u2026<\/td><td>\u2026<\/td><td>\u2026<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"is-style-bstn-paragraph-documentation-body\">It should also be noted that predicates need not be applied to fields which are returned in the <code>SELECT<\/code> statement and operate independently of them; for example, the below is a perfectly valid query with a <code>WHERE<\/code> clause and will return the result, filtering on the unseen <code>first_name<\/code> field which is not returned in the result:<\/p>\n\n\n\n<div class=\"wp-block-bstn-blocks-code-snippet bstn-blocks-code-snippet\" data-code-snippet=\"true\"><div class=\"bstn-blocks-code-snippet__title-bar\"><span class=\"bstn-blocks-code-snippet__title\">Code Example<\/span><button class=\"bstn-blocks-code-snippet__copy-trigger\" data-copy-to-clipboard=\"true\"><svg viewbox=\"0 0 12 13\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"bstn-blocks-code-snippet__copy-trigger-icon\"><path d=\"M10.875.5h-7.5c-.633 0-1.125.516-1.125 1.125V2.75H1.125C.492 2.75 0 3.266 0 3.875v7.5A1.11 1.11 0 001.125 12.5h7.5c.61 0 1.125-.492 1.125-1.125V10.25h1.125c.61 0 1.125-.492 1.125-1.125v-7.5A1.14 1.14 0 0010.875.5zm-2.39 10.875h-7.22c-.093 0-.14-.047-.14-.14v-7.22c0-.07.047-.14.14-.14h.985v5.25a1.11 1.11 0 001.125 1.125h5.25v.984c0 .094-.07.141-.14.141zm2.25-2.25h-7.22c-.093 0-.14-.047-.14-.14v-7.22c0-.07.047-.14.14-.14h7.22c.07 0 .14.07.14.14v7.22c0 .093-.07.14-.14.14z\" fill=\"currentColor\"><\/path><\/svg><span data-copy-to-clipboard-text=\"true\">Copy<\/span><\/button><\/div><pre class=\"bstn-blocks-code-snippet__code-snippet-area match-braces line-numbers language-sql\" data-language=\"sql\"><code>SELECT last_name, gender, hire_date FROM employees WHERE first_name = \"Georgi\";<\/code><\/pre><\/div>\n\n\n\n<p class=\"is-style-bstn-paragraph-documentation-body\">That being said, it is considered a best practice to include the fields used in the predicate for the <code>WHERE<\/code> clause in the <code>SELECT<\/code> which makes the logic of the query easier to read, and also to ensure that the desired result is being returned correctly. As such, the below would be preferred to the query above:<\/p>\n\n\n\n<div class=\"wp-block-bstn-blocks-code-snippet bstn-blocks-code-snippet\" data-code-snippet=\"true\"><div class=\"bstn-blocks-code-snippet__title-bar\"><span class=\"bstn-blocks-code-snippet__title\">Code Example<\/span><button class=\"bstn-blocks-code-snippet__copy-trigger\" data-copy-to-clipboard=\"true\"><svg viewbox=\"0 0 12 13\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"bstn-blocks-code-snippet__copy-trigger-icon\"><path d=\"M10.875.5h-7.5c-.633 0-1.125.516-1.125 1.125V2.75H1.125C.492 2.75 0 3.266 0 3.875v7.5A1.11 1.11 0 001.125 12.5h7.5c.61 0 1.125-.492 1.125-1.125V10.25h1.125c.61 0 1.125-.492 1.125-1.125v-7.5A1.14 1.14 0 0010.875.5zm-2.39 10.875h-7.22c-.093 0-.14-.047-.14-.14v-7.22c0-.07.047-.14.14-.14h.985v5.25a1.11 1.11 0 001.125 1.125h5.25v.984c0 .094-.07.141-.14.141zm2.25-2.25h-7.22c-.093 0-.14-.047-.14-.14v-7.22c0-.07.047-.14.14-.14h7.22c.07 0 .14.07.14.14v7.22c0 .093-.07.14-.14.14z\" fill=\"currentColor\"><\/path><\/svg><span data-copy-to-clipboard-text=\"true\">Copy<\/span><\/button><\/div><pre class=\"bstn-blocks-code-snippet__code-snippet-area match-braces line-numbers language-sql\" data-language=\"sql\"><code>SELECT first_name, last_name, gender, hire_date FROM employees WHERE first_name = \"Georgi\";<\/code><\/pre><\/div>\n\n\n\n<p class=\"is-style-bstn-paragraph-documentation-body\">In this case we would be able to examine the <code>first_name<\/code> field returned to verify that our predicate is returning the correct result, which would not be possible with the previous query.<\/p>\n\n\n\n<p class=\"is-style-bstn-paragraph-documentation-body\">Finally, the predicate for a <code>WHERE<\/code> clause can be any expression (or combination of expressions) as long it evaluates to <code>True<\/code> or <code>False<\/code>; this allows specifying detailed criteria for the result returned by a query through usage of logical operators such as <code>AND<\/code> and <code>OR<\/code> (covered in greater detail in a later section):<\/p>\n\n\n\n<div class=\"wp-block-bstn-blocks-code-snippet bstn-blocks-code-snippet\" data-code-snippet=\"true\"><div class=\"bstn-blocks-code-snippet__title-bar\"><span class=\"bstn-blocks-code-snippet__title\">Code Example<\/span><button class=\"bstn-blocks-code-snippet__copy-trigger\" data-copy-to-clipboard=\"true\"><svg viewbox=\"0 0 12 13\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"bstn-blocks-code-snippet__copy-trigger-icon\"><path d=\"M10.875.5h-7.5c-.633 0-1.125.516-1.125 1.125V2.75H1.125C.492 2.75 0 3.266 0 3.875v7.5A1.11 1.11 0 001.125 12.5h7.5c.61 0 1.125-.492 1.125-1.125V10.25h1.125c.61 0 1.125-.492 1.125-1.125v-7.5A1.14 1.14 0 0010.875.5zm-2.39 10.875h-7.22c-.093 0-.14-.047-.14-.14v-7.22c0-.07.047-.14.14-.14h.985v5.25a1.11 1.11 0 001.125 1.125h5.25v.984c0 .094-.07.141-.14.141zm2.25-2.25h-7.22c-.093 0-.14-.047-.14-.14v-7.22c0-.07.047-.14.14-.14h7.22c.07 0 .14.07.14.14v7.22c0 .093-.07.14-.14.14z\" fill=\"currentColor\"><\/path><\/svg><span data-copy-to-clipboard-text=\"true\">Copy<\/span><\/button><\/div><pre class=\"bstn-blocks-code-snippet__code-snippet-area match-braces line-numbers language-sql\" data-language=\"sql\"><code>SELECT * FROM employees WHERE first_name = \"Georgi\" AND hire_date > \"1995-01-01\";<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>emp_no<\/strong><\/td><td><strong>birth_date<\/strong><\/td><td><strong>first_name<\/strong><\/td><td><strong>last_name<\/strong><\/td><td><strong>gender<\/strong><\/td><td><strong>hire_date<\/strong><\/td><\/tr><tr><td>11430<\/td><td>1957-01-23<\/td><td>Georgi<\/td><td>Klassen<\/td><td>M<\/td><td>1996-02-27<\/td><\/tr><tr><td>15220<\/td><td>1957-08-03<\/td><td>Georgi<\/td><td>Panienski<\/td><td>F<\/td><td>1995-07-23<\/td><\/tr><tr><td>15689<\/td><td>1962-09-14<\/td><td>Georgi<\/td><td>Capobianchi<\/td><td>M<\/td><td>1995-03-11<\/td><\/tr><tr><td>35108<\/td><td>1955-03-17<\/td><td>Georgi<\/td><td>Dratva<\/td><td>F<\/td><td>1998-02-05<\/td><\/tr><tr><td>45348<\/td><td>1962-08-22<\/td><td>Georgi<\/td><td>Nivat<\/td><td>F<\/td><td>1998-08-28<\/td><\/tr><tr><td>\u2026<\/td><td>\u2026<\/td><td>\u2026<\/td><td>\u2026<\/td><td>\u2026<\/td><td>\u2026<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"is-style-bstn-paragraph-documentation-body\">We can see how even simple <code>SELECT<\/code> statements combined with a single <code>WHERE<\/code> clause some predicates begin to unlock the true power of SQL to dive into data!<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:25%\"><\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-bstn-blocks-content-navigation-footer bstn-blocks-content-nav-footer\"><div class=\"bstn-blocks-content-nav-footer__links-container\"><div class=\"bstn-blocks-content-nav-footer__link-container\"><p class=\"bstn-blocks-content-nav-footer__link-title bstn-blocks-content-nav-footer__link--desktop\">Previous<\/p><a class=\"bstn-blocks-content-nav-footer__link\" href=\"https:\/\/brainstation.io\/learn\/sql\/clause\"><span class=\"bstn-blocks-content-nav-footer__link-icon-wrapper bstn-blocks-content-nav-footer__link-icon-wrapper--left\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewbox=\"0 0 18 18\" fill=\"none\" class=\"bstn-blocks-content-nav-footer__link-icon bstn-blocks-content-nav-footer__link-icon--left\"><path fill=\"currentColor\" d=\"M6.345 12.743a1 1 0 001.31 1.511l5.477-4.749a1 1 0 000-1.511l-5.477-4.75a1.001 1.001 0 00-1.31 1.512l4.606 3.993-4.606 3.994z\"><\/path><\/svg><\/span><span class=\"bstn-blocks-content-nav-footer__link-text bstn-blocks-content-nav-footer__link--desktop\">SQL Clause<\/span><\/a><\/div><div class=\"bstn-blocks-content-nav-footer__link-container\"><p class=\"bstn-blocks-content-nav-footer__link-title\">Next<\/p><a class=\"bstn-blocks-content-nav-footer__link\" href=\"https:\/\/brainstation.io\/learn\/sql\/order-by\"><span class=\"bstn-blocks-content-nav-footer__link-text\">SQL Order By<\/span><span class=\"bstn-blocks-content-nav-footer__link-icon-wrapper bstn-blocks-content-nav-footer__link-icon-wrapper--right\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewbox=\"0 0 18 18\" fill=\"none\" class=\"bstn-blocks-content-nav-footer__link-icon bstn-blocks-content-nav-footer__link-icon--right\"><path fill=\"currentColor\" d=\"M6.345 12.743a1 1 0 001.31 1.511l5.477-4.749a1 1 0 000-1.511l-5.477-4.75a1.001 1.001 0 00-1.31 1.512l4.606 3.993-4.606 3.994z\"><\/path><\/svg><\/span><\/a><\/div><\/div><\/div>\n\n\n\n<div class=\"wp-block-bstn-blocks-container bstn-blocks-container bstn-blocks-container--dark-blue bstn-blocks-container--64 bstn-blocks-container--negative-container bstn-blocks-container--overflow-hidden\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewbox=\"0 0 1140 621\" fill=\"none\" class=\"bstn-blocks-container__bg-flair\"><g opacity=\"0.55\"><path stroke=\"#3C4556\" strokelinecap=\"square\" d=\"M60.026 736.434V203.02\"><\/path><path stroke=\"#3C4556\" strokelinecap=\"square\" d=\"M60.364 436.132L-120 436.131l180.364.001zm0-99.873H-120 60.364zm0-99.872H-120 60.364zM128 536.004h-248 248z\" cliprule=\"evenodd\"><\/path><path fill=\"#3C4556\" fillrule=\"evenodd\" d=\"M57.518 535.982a2.286 2.286 0 114.572 0 2.286 2.286 0 01-4.572 0zm0-99.836a2.286 2.286 0 114.572-.002 2.286 2.286 0 01-4.572.002zm0-99.837a2.286 2.286 0 114.572-.002 2.286 2.286 0 01-4.572.002zm0-99.837a2.286 2.286 0 114.572-.002 2.286 2.286 0 01-4.572.002z\" cliprule=\"evenodd\"><\/path><\/g><g opacity=\"0.55\"><path stroke=\"#3C4556\" strokelinecap=\"square\" d=\"M979.195-28.206V397.98m81.185-524.745V397.98\"><\/path><path stroke=\"#3C4556\" strokelinecap=\"square\" d=\"M1141.45 168.46H964h177.45zm0 98.334H964h177.45zm0 98.333H964h177.45zm66.55-295H964h244z\" cliprule=\"evenodd\"><\/path><path fill=\"#3C4556\" fillrule=\"evenodd\" d=\"M1138.66 70.148a2.244 2.244 0 104.49 0 2.246 2.246 0 10-4.49-.001zm-80.21 0c0 1.243 1.01 2.251 2.25 2.251s2.25-1.008 2.25-2.251c0-1.243-1.01-2.251-2.25-2.251s-2.25 1.008-2.25 2.25zm-81.707 0a2.25 2.25 0 104.5.004 2.25 2.25 0 00-4.5-.005zm81.707 98.299a2.252 2.252 0 002.25 2.251 2.252 2.252 0 000-4.503 2.253 2.253 0 00-2.25 2.252zm-81.707 0a2.25 2.25 0 104.498 0 2.25 2.25 0 00-2.249-2.252 2.25 2.25 0 00-2.249 2.252zm161.917-.001a2.244 2.244 0 104.49 0 2.246 2.246 0 10-4.49 0zm0 98.299a2.244 2.244 0 104.49 0 2.246 2.246 0 10-4.49 0zm-80.21 0c0 1.243 1.01 2.251 2.25 2.251s2.25-1.008 2.25-2.251c0-1.243-1.01-2.251-2.25-2.251s-2.25 1.008-2.25 2.251zm-81.707 0a2.25 2.25 0 104.5.002 2.25 2.25 0 00-4.5-.002zm81.707 98.299c0 1.243 1.01 2.251 2.25 2.251s2.25-1.008 2.25-2.251c0-1.243-1.01-2.251-2.25-2.251s-2.25 1.008-2.25 2.251zm-81.707 0a2.25 2.25 0 104.5.002 2.25 2.25 0 00-4.5-.002zm161.917 0a2.244 2.244 0 104.49 0 2.246 2.246 0 10-4.49 0z\" cliprule=\"evenodd\"><\/path><\/g><\/svg><div class=\"bstn-blocks-container__wrapper bstn-blocks-container__wrapper--readable-width bstn-blocks-container__wrapper--negative-container\">\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-2 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-bstn-blocks-heading bstn-blocks-heading bstn-blocks-heading--h2 has-text-align-left bstn-blocks-heading--divider\"><h2 class=\"bstn-blocks-heading__heading-element\">Learn SQL Today<\/h2><\/div>\n\n\n\n<p class=\"is-style-bstn-paragraph-documentation-body\">Get hands-on experience writing code with interactive tutorials in our free online learning platform.<\/p>\n\n\n\n<div style=\"height:16px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<ul class=\"wp-block-list is-style-kg-list-checklist-alternate\"><li>Free and fun<\/li><li>Designed for beginners<\/li><li>No downloads or setup required<\/li><\/ul>\n\n\n\n<div style=\"height:16px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button is-style-bstn-button-primary\"><a class=\"wp-block-button__link\" href=\"https:\/\/brainstation.io\/learn\/sql\" target=\"_blank\" rel=\"noreferrer noopener\">Get Started<\/a><\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-video\"><video autoplay loop muted src=\"https:\/\/d3ghupt9z9s6o0.cloudfront.net\/app\/uploads\/2022\/04\/13110644\/SQL-promo-clip.mp4\" playsinline><\/video><\/figure>\n<\/div>\n<\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The SQL WHERE clause is used to alter the behavior of a SELECT statement or other SQL commands that are applied to rows of data, in order to either restrict the rows returned by a query or the records affected by other statement types (DELETE, UPDATE, etc.) The SQL WHERE clause is the simplest clause [&hellip;]<\/p>\n","protected":false},"featured_media":0,"parent":130267,"menu_order":0,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-130387","codex-reference","type-codex-reference","status-publish","format-standard","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/brainstation.io\/wp\/api\/wp\/v2\/codex-reference\/130387","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/brainstation.io\/wp\/api\/wp\/v2\/codex-reference"}],"about":[{"href":"https:\/\/brainstation.io\/wp\/api\/wp\/v2\/types\/codex-reference"}],"version-history":[{"count":8,"href":"https:\/\/brainstation.io\/wp\/api\/wp\/v2\/codex-reference\/130387\/revisions"}],"predecessor-version":[{"id":135479,"href":"https:\/\/brainstation.io\/wp\/api\/wp\/v2\/codex-reference\/130387\/revisions\/135479"}],"up":[{"embeddable":true,"href":"https:\/\/brainstation.io\/wp\/api\/wp\/v2\/codex-reference\/130267"}],"wp:attachment":[{"href":"https:\/\/brainstation.io\/wp\/api\/wp\/v2\/media?parent=130387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/brainstation.io\/wp\/api\/wp\/v2\/categories?post=130387"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/brainstation.io\/wp\/api\/wp\/v2\/tags?post=130387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}