{"id":157,"date":"2015-11-30T16:00:55","date_gmt":"2015-11-30T09:00:55","guid":{"rendered":"http:\/\/www.sqlitetutorial.net\/?page_id=157"},"modified":"2024-04-12T06:24:38","modified_gmt":"2024-04-11T23:24:38","slug":"sqlite-where","status":"publish","type":"page","link":"https:\/\/www.sqlitetutorial.net\/sqlite-where\/","title":{"rendered":"SQLite Where"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to use SQLite <code>WHERE<\/code> clause to specify the search condition for rows returned by the query.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to SQLite WHERE clause<\/h2>\n\n\n\n<p>The <code>WHERE<\/code> clause is an optional clause of the <code><a href=\"https:\/\/www.sqlitetutorial.net\/sqlite-select\/\">SELECT<\/a><\/code> statement. It appears after the <code>FROM<\/code> clause as the following statement:<\/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  column_list\n<span class=\"hljs-keyword\">FROM<\/span>\n  <span class=\"hljs-keyword\">TABLE<\/span>\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>In this example, you add a <code>WHERE<\/code> clause to the <code>SELECT<\/code> statement to filter rows returned by the query. When evaluating a <code>SELECT<\/code> statement with a <code>WHERE<\/code> clause, SQLite uses the following steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>First, check the table in the <code>FROM<\/code> clause.<\/li>\n\n\n\n<li>Second, evaluate the conditions in the <code>WHERE<\/code> clause to get the rows that met these conditions.<\/li>\n\n\n\n<li>Third, make the final result set based on the rows in the previous step with columns in the <code>SELECT<\/code> clause.<\/li>\n<\/ol>\n\n\n\n<p>The search condition in the <code>WHERE<\/code> has the following form:<\/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\">left_expression COMPARISON_OPERATOR right_expression<\/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>For example, you can form a search condition as follows:<\/p>\n\n\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\">WHERE column_1 = 100;\n\nWHERE column_2 IN (1,2,3);\n\nWHERE column_3 LIKE 'An%';\n\nWHERE column_4 BETWEEN 10 AND 20;<\/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>\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.sqlitetutorial.net\/sqlite-update\/\">UPDATE<\/a><\/code> and <code><a href=\"https:\/\/www.sqlitetutorial.net\/sqlite-delete\/\">DELETE<\/a><\/code> statements.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">SQLite comparison operators<\/h3>\n\n\n\n<p>A comparison operator tests if two expressions are the same. The following table illustrates the comparison operators that you can use to construct expressions:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Operator<\/th><th>Meaning<\/th><\/tr><tr><td>=<\/td><td>Equal to<\/td><\/tr><tr><td>&lt;&gt; or !=<\/td><td>Not equal to<\/td><\/tr><tr><td>&lt;<\/td><td>Less than<\/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<h3 class=\"wp-block-heading\">SQLite logical operators<\/h3>\n\n\n\n<p>Logical operators allow you to test the truth of some expressions. A logical operator returns 1, 0, or a NULL value.<\/p>\n\n\n\n<p>Notice that SQLite does not provide Boolean data type therefore 1 means TRUE, and 0 means FALSE.<\/p>\n\n\n\n<p>The following table illustrates the SQLite logical operators:<\/p>\n\n\n\n<figure class=\"wp-block-table table table-bordered\"><table><tbody><tr><th>Operator<\/th><th>Meaning<\/th><\/tr><tr><td>ALL<\/td><td>returns 1 if all expressions are 1.<\/td><\/tr><tr><td>AND<\/td><td>returns 1 if both expressions are 1, and 0 if one of the expressions is 0.<\/td><\/tr><tr><td>ANY<\/td><td>returns 1 if any one of a set of comparisons is 1.<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlitetutorial.net\/sqlite-between\/\">BETWEEN<\/a><\/td><td>returns 1 if a value is within a range.<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlitetutorial.net\/sqlite-exists\/\">EXISTS<\/a><\/td><td>returns 1 if a subquery contains any rows.<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlitetutorial.net\/sqlite-in\/\">IN<\/a><\/td><td>returns 1 if a value is in a list of values.<\/td><\/tr><tr><td><a href=\"https:\/\/www.sqlitetutorial.net\/sqlite-like\/\">LIKE<\/a><\/td><td>returns 1 if a value matches a pattern<\/td><\/tr><tr><td>NOT<\/td><td>reverses the value of other operators such as NOT EXISTS, NOT IN, NOT BETWEEN, etc.<\/td><\/tr><tr><td>OR<\/td><td>returns true if either expression is 1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">SQLite WHERE clause examples<\/h2>\n\n\n\n<p>We will use the <code>tracks<\/code> table in the <a href=\"https:\/\/www.sqlitetutorial.net\/sqlite-sample-database\/\">sample database<\/a> to illustrate how to use the <code>WHERE<\/code> clause.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"174\" height=\"224\" src=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2018\/11\/tracks.png\" alt=\"\" class=\"wp-image-1558\"\/><\/figure>\n\n\n\n<p>The equality operator (<code>=<\/code>) is the most commonly used operator. For example, the following query uses the <code>WHERE<\/code> clause the equality operator to find all the tracks in the album id 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   <span class=\"hljs-keyword\">name<\/span>,\n   milliseconds,\n   <span class=\"hljs-keyword\">bytes<\/span>,\n   albumid\n<span class=\"hljs-keyword\">FROM<\/span>\n   tracks\n<span class=\"hljs-keyword\">WHERE<\/span>\n   albumid = <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.sqlitetutorial.net\/tryit\/query\/sqlite-where\/#1\" target=\"_blank\" rel=\"noopener noreferrer\">Try It<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"493\" height=\"219\" src=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2015\/11\/SQLite-WHERE-clause.jpg\" alt=\"SQLite WHERE clause\" class=\"wp-image-159\" srcset=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2015\/11\/SQLite-WHERE-clause.jpg 493w, https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2015\/11\/SQLite-WHERE-clause-300x133.jpg 300w\" sizes=\"auto, (max-width: 493px) 100vw, 493px\" \/><\/figure>\n\n\n\n<p>SQLite compares the values stored in the <code>AlbumId<\/code> column with a literal value <code>1<\/code> to test if they are equal. Only the rows that satisfy the condition are returned.<\/p>\n\n\n\n<p>When comparing two values, you need to ensure they are the same data type. You should compare numbers with numbers, string with strings, and so on.<\/p>\n\n\n\n<p>In case you compare values in different data types e.g., a string with a number, SQLite has to perform implicit data type conversions, but in general, you should avoid doing this.<\/p>\n\n\n\n<p>You use the logical operator to combine expressions. For example, to get tracks of the album 1 that have the length greater than 200,000 milliseconds, you use the following statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" 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  <span class=\"hljs-keyword\">name<\/span>,\n  milliseconds,\n  <span class=\"hljs-keyword\">bytes<\/span>,\n  albumid\n<span class=\"hljs-keyword\">FROM<\/span>\n  tracks\n<span class=\"hljs-keyword\">WHERE<\/span>\n  albumid = <span class=\"hljs-number\">1<\/span>\n  <span class=\"hljs-keyword\">AND<\/span> milliseconds &gt; <span class=\"hljs-number\">250000<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><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.sqlitetutorial.net\/tryit\/query\/sqlite-where\/#2\" target=\"_blank\" rel=\"noopener noreferrer\">Try It<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"493\" height=\"102\" src=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2015\/11\/SQLite-WHERE-clause-comparison-operator.jpg\" alt=\"SQLite WHERE clause comparison operator\" class=\"wp-image-161\" srcset=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2015\/11\/SQLite-WHERE-clause-comparison-operator.jpg 493w, https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2015\/11\/SQLite-WHERE-clause-comparison-operator-300x62.jpg 300w\" sizes=\"auto, (max-width: 493px) 100vw, 493px\" \/><\/figure>\n\n\n\n<p>The statement used two expressions <code>albumid = 1<\/code> and <code>milliseconds &gt; 250000<\/code>. It uses the <code>AND<\/code> logical operator to combine these expressions.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"487\" height=\"300\" src=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2015\/11\/SQLite-WHERE-multiple-conditions.jpg\" alt=\"SQLite WHERE multiple conditions\" class=\"wp-image-162\" srcset=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2015\/11\/SQLite-WHERE-multiple-conditions.jpg 487w, https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2015\/11\/SQLite-WHERE-multiple-conditions-300x185.jpg 300w\" sizes=\"auto, (max-width: 487px) 100vw, 487px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Using WHERE clause with LIKE operator example<\/h3>\n\n\n\n<p>Sometimes, you may not remember exactly the data you want to search. In this case, you perform an inexact search using the <code><a href=\"https:\/\/www.sqlitetutorial.net\/sqlite-like\/\">LIKE<\/a><\/code> operator.<\/p>\n\n\n\n<p>For example, to find which tracks were composed by <code>Smith<\/code>, you use the <code>LIKE<\/code> operator as follows:<\/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\"><span class=\"hljs-keyword\">SELECT<\/span>\n  <span class=\"hljs-keyword\">name<\/span>,\n  albumid,\n  composer\n<span class=\"hljs-keyword\">FROM<\/span>\n  tracks\n<span class=\"hljs-keyword\">WHERE<\/span>\n  composer <span class=\"hljs-keyword\">LIKE<\/span> <span class=\"hljs-string\">'%Smith%'<\/span>\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span>\n  albumid;<\/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><a class=\"sql\" href=\"https:\/\/www.sqlitetutorial.net\/tryit\/query\/sqlite-where\/#3\" target=\"_blank\" rel=\"noopener noreferrer\">Try It<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"610\" height=\"242\" src=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2015\/11\/SQLite-WHERE-with-LIKE-operator.jpg\" alt=\"SQLite WHERE with LIKE operator\" class=\"wp-image-163\" srcset=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2015\/11\/SQLite-WHERE-with-LIKE-operator.jpg 610w, https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2015\/11\/SQLite-WHERE-with-LIKE-operator-300x119.jpg 300w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/figure>\n\n\n\n<p>You get tracks composed by R.A. Smith-Diesel, Adrian Smith, etc.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using SQLite WHERE clause with the IN operator example<\/h3>\n\n\n\n<p>The <code><a href=\"https:\/\/www.sqlitetutorial.net\/sqlite-in\/\">IN<\/a><\/code> operator allows you to check whether a value is in a list of a comma-separated list of values. For example, to find tracks that have media type id is 2 or 3, you use the <code>IN<\/code> operator as shown in the following statement:<\/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\t<span class=\"hljs-keyword\">name<\/span>,\n\talbumid,\n\tmediatypeid\n<span class=\"hljs-keyword\">FROM<\/span>\n\ttracks\n<span class=\"hljs-keyword\">WHERE<\/span>\n\tmediatypeid <span class=\"hljs-keyword\">IN<\/span> (<span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>);<\/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.sqlitetutorial.net\/tryit\/query\/sqlite-where\/#4\" target=\"_blank\" rel=\"noopener noreferrer\">Try It<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"439\" height=\"241\" src=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2015\/11\/SQLite-WHERE-with-IN-operator.jpg\" alt=\"SQLite WHERE with IN operator\" class=\"wp-image-164\" srcset=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2015\/11\/SQLite-WHERE-with-IN-operator.jpg 439w, https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2015\/11\/SQLite-WHERE-with-IN-operator-300x165.jpg 300w\" sizes=\"auto, (max-width: 439px) 100vw, 439px\" \/><\/figure>\n\n\n\n<p>In this tutorial, you have learned how to use the SQLite <code>WHERE<\/code> clause to filter rows in the final result set using comparison and logical operators.<\/p>\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=\"157\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlitetutorial.net\/sqlite-where\/\"\n\t\t\t\tdata-post-title=\"SQLite 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=\"157\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlitetutorial.net\/sqlite-where\/\"\n\t\t\t\tdata-post-title=\"SQLite 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>In this tutorial, you will learn how to use SQLite WHERE clause to specify the search condition for rows returned by the query.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2,"menu_order":3,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-157","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>SQLite WHERE - Filter Rows in a Result Set<\/title>\n<meta name=\"description\" content=\"This tutorial shows you how to use SQLite WHERE clause to filter rows in a result set returned by the SELECT statement.\" \/>\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.sqlitetutorial.net\/sqlite-where\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQLite WHERE - Filter Rows in a Result Set\" \/>\n<meta property=\"og:description\" content=\"This tutorial shows you how to use SQLite WHERE clause to filter rows in a result set returned by the SELECT statement.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlitetutorial.net\/sqlite-where\/\" \/>\n<meta property=\"og:site_name\" content=\"SQLite Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-11T23:24:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2018\/11\/tracks.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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-where\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-where\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/www.sqlitetutorial.net\/#\/schema\/person\/6d69b968cad0102e30d6694ed8dc6427\"},\"headline\":\"SQLite Where\",\"datePublished\":\"2015-11-30T09:00:55+00:00\",\"dateModified\":\"2024-04-11T23:24:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-where\/\"},\"wordCount\":656,\"image\":{\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-where\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2018\/11\/tracks.png\",\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-where\/\",\"url\":\"https:\/\/www.sqlitetutorial.net\/sqlite-where\/\",\"name\":\"SQLite WHERE - Filter Rows in a Result Set\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlitetutorial.net\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-where\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-where\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2018\/11\/tracks.png\",\"datePublished\":\"2015-11-30T09:00:55+00:00\",\"dateModified\":\"2024-04-11T23:24:38+00:00\",\"description\":\"This tutorial shows you how to use SQLite WHERE clause to filter rows in a result set returned by the SELECT statement.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-where\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlitetutorial.net\/sqlite-where\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-where\/#primaryimage\",\"url\":\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2018\/11\/tracks.png\",\"contentUrl\":\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2018\/11\/tracks.png\",\"width\":174,\"height\":224,\"caption\":\"SQLite trunc() function - sample table\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-where\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlitetutorial.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQLite Where\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlitetutorial.net\/#website\",\"url\":\"https:\/\/www.sqlitetutorial.net\/\",\"name\":\"SQLite Tutorial\",\"description\":\"A Step-by-step SQLite Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlitetutorial.net\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlitetutorial.net\/#\/schema\/person\/6d69b968cad0102e30d6694ed8dc6427\",\"name\":\"admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQLite WHERE - Filter Rows in a Result Set","description":"This tutorial shows you how to use SQLite WHERE clause to filter rows in a result set returned by the SELECT statement.","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.sqlitetutorial.net\/sqlite-where\/","og_locale":"en_US","og_type":"article","og_title":"SQLite WHERE - Filter Rows in a Result Set","og_description":"This tutorial shows you how to use SQLite WHERE clause to filter rows in a result set returned by the SELECT statement.","og_url":"https:\/\/www.sqlitetutorial.net\/sqlite-where\/","og_site_name":"SQLite Tutorial","article_modified_time":"2024-04-11T23:24:38+00:00","og_image":[{"url":"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2018\/11\/tracks.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.sqlitetutorial.net\/sqlite-where\/#article","isPartOf":{"@id":"https:\/\/www.sqlitetutorial.net\/sqlite-where\/"},"author":{"name":"admin","@id":"https:\/\/www.sqlitetutorial.net\/#\/schema\/person\/6d69b968cad0102e30d6694ed8dc6427"},"headline":"SQLite Where","datePublished":"2015-11-30T09:00:55+00:00","dateModified":"2024-04-11T23:24:38+00:00","mainEntityOfPage":{"@id":"https:\/\/www.sqlitetutorial.net\/sqlite-where\/"},"wordCount":656,"image":{"@id":"https:\/\/www.sqlitetutorial.net\/sqlite-where\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2018\/11\/tracks.png","inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.sqlitetutorial.net\/sqlite-where\/","url":"https:\/\/www.sqlitetutorial.net\/sqlite-where\/","name":"SQLite WHERE - Filter Rows in a Result Set","isPartOf":{"@id":"https:\/\/www.sqlitetutorial.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqlitetutorial.net\/sqlite-where\/#primaryimage"},"image":{"@id":"https:\/\/www.sqlitetutorial.net\/sqlite-where\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2018\/11\/tracks.png","datePublished":"2015-11-30T09:00:55+00:00","dateModified":"2024-04-11T23:24:38+00:00","description":"This tutorial shows you how to use SQLite WHERE clause to filter rows in a result set returned by the SELECT statement.","breadcrumb":{"@id":"https:\/\/www.sqlitetutorial.net\/sqlite-where\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlitetutorial.net\/sqlite-where\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlitetutorial.net\/sqlite-where\/#primaryimage","url":"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2018\/11\/tracks.png","contentUrl":"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2018\/11\/tracks.png","width":174,"height":224,"caption":"SQLite trunc() function - sample table"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlitetutorial.net\/sqlite-where\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlitetutorial.net\/"},{"@type":"ListItem","position":2,"name":"SQLite Where"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlitetutorial.net\/#website","url":"https:\/\/www.sqlitetutorial.net\/","name":"SQLite Tutorial","description":"A Step-by-step SQLite Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlitetutorial.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlitetutorial.net\/#\/schema\/person\/6d69b968cad0102e30d6694ed8dc6427","name":"admin"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlitetutorial.net\/wp-json\/wp\/v2\/pages\/157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlitetutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sqlitetutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlitetutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlitetutorial.net\/wp-json\/wp\/v2\/comments?post=157"}],"version-history":[{"count":4,"href":"https:\/\/www.sqlitetutorial.net\/wp-json\/wp\/v2\/pages\/157\/revisions"}],"predecessor-version":[{"id":2977,"href":"https:\/\/www.sqlitetutorial.net\/wp-json\/wp\/v2\/pages\/157\/revisions\/2977"}],"up":[{"embeddable":true,"href":"https:\/\/www.sqlitetutorial.net\/wp-json\/wp\/v2\/pages\/2"}],"wp:attachment":[{"href":"https:\/\/www.sqlitetutorial.net\/wp-json\/wp\/v2\/media?parent=157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}