{"id":4465,"date":"2018-04-06T15:10:49","date_gmt":"2018-04-06T15:10:49","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2018\/04\/06\/how-to-use-like-in-sql\/"},"modified":"2023-06-12T10:33:39","modified_gmt":"2023-06-12T14:33:39","slug":"how-to-use-like-in-sql","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/","title":{"rendered":"How to Use &#8220;Like&#8221; in SQL"},"content":{"rendered":"<p>We have already been learning about the basics of SQL. We\u2019ve learned about <a href=\"\/support\/server\/databases\/what-is-sql\/\">SQL itself<\/a> and how to write <a href=\"\/support\/server\/databases\/how-to-write-select-statements\/\">select statements<\/a>.<\/p>\n<p>We have also seen how we can <a href=\"\/support\/server\/databases\/how-to-drop-tables-and-columns-with-sql\/\">create and delete tables and columns<\/a>. Now, we\u2019re going to learn a little bit about how to use the <em>Like<\/em> operator with wildcards to find very specific records in our database tables. For example, we can query our database for all people with first names that begin with the letter \u201cC\u201d.<\/p>\n<p><!-- The code --><\/p>\n<pre class=\"code_block\"><span style=\"color:blue;\">SELECT<\/span> * <span style=\"color:blue;\">FROM<\/span> <span style=\"color:green;\">respondents<\/span> <span style=\"color:blue;\">SELECT<\/span> WHERE\n<span style=\"color:green;\">\"first_name\"<\/span> <span style=\"color:blue;\">LIKE<\/span> <span style=\"color:green;\">\"c%\"<\/span>;<\/pre>\n<p><!-- Some Explanations of the code --><br>\n<\/p><center> <a href=\"\/support\/images\/stories\/generic\/sql_like.png\" rel=\"lightbox-0\"><img decoding=\"async\" class=\"std_ss\" src=\"\/support\/images\/stories\/generic\/sql_like.png\" alt=\"search results\" style=\"width:auto;\"><\/a>\n<div style=\"clear:both;\"><\/div>\n<p><\/p><\/center>\n<p>Let\u2019s break down the above statement. You will recognize the <em>select<\/em> statement that starts this line. This will let SQL know we want to select (return) some records. But we can get more specific.<\/p>\n<p>Next, we have the <em>from<\/em> clause that tells SQL which table in the database we\u2019re interested in. In this case, we\u2019re working with our \u201crespondents\u201d table again. This table contains the names and information about the people who have signed up to receive a newsletter.<\/p>\n<p>The important <em>where<\/em> clause lets SQL know which column of the table we\u2019re interested in. In this case, we\u2019re working with the \u201cfirst_name\u201d column of the table. And the <em>like<\/em> operator lets us get specific.<\/p>\n<p>We are using a <em>wildcard<\/em> to search only for records where the \u201cfirst_name\u201d begins with the letter C. That wildcard looks like this: <code>\"c%\"<\/code>. The quotes open and close the wildcard. The percent sign after the \u201cc\u201d means we don\u2019t care what cames after the first letter, as long as the first letter is a C.<\/p>\n<p>So we are basically telling SQL that we would like to get some records \u201clike\u201d what matches our wildcard.<\/p>\n<div class=\"alert alert-info\" role=\"alert\">A quick Google search will provide you with a wide list of accepted wildcard characters. There are so many good resources out there I hesitate to name one.<\/div>\n<p>We have shown you some basic syntax for the <em>like<\/em> operator and how you can use it in SQL. Stay tuned in our series as we\u2019re going to cover more SQL-related tips and tricks. Let us know in the comments below if you have any questions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have already been learning about the basics of SQL. We\u2019ve learned about SQL itself and how to write select statements. We have also seen how we can create and delete tables and columns. Now, we\u2019re going to learn a little bit about how to use the Like operator with wildcards to find very specific<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/\"> Read More ><\/a><\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4305],"tags":[],"class_list":["post-4465","post","type-post","status-publish","format-standard","hentry","category-databases"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Use &quot;Like&quot; in SQL | InMotion Hosting<\/title>\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.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Use &quot;Like&quot; in SQL | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"We have already been learning about the basics of SQL. We\u2019ve learned about SQL itself and how to write select statements. We have also seen how we can create and delete tables and columns. Now, we\u2019re going to learn a little bit about how to use the Like operator with wildcards to find very specific Read More &gt;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-06T15:10:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-12T14:33:39+00:00\" \/>\n<meta name=\"author\" content=\"Christopher Maiorana\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Christopher Maiorana\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/\"},\"author\":{\"name\":\"Christopher Maiorana\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/c6922c56c84e17079fd558e07b7ef72f\"},\"headline\":\"How to Use &#8220;Like&#8221; in SQL\",\"datePublished\":\"2018-04-06T15:10:49+00:00\",\"dateModified\":\"2023-06-12T14:33:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/\"},\"wordCount\":358,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"articleSection\":[\"Working with Databases\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/\",\"name\":\"How to Use \\\"Like\\\" in SQL | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2018-04-06T15:10:49+00:00\",\"dateModified\":\"2023-06-12T14:33:39+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Use &#8220;Like&#8221; in SQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/c6922c56c84e17079fd558e07b7ef72f\",\"name\":\"Christopher Maiorana\",\"description\":\"Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/chris-m-4623144b\/\"],\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/christopherm\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Use \"Like\" in SQL | InMotion Hosting","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.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/","og_locale":"en_US","og_type":"article","og_title":"How to Use \"Like\" in SQL | InMotion Hosting","og_description":"We have already been learning about the basics of SQL. We\u2019ve learned about SQL itself and how to write select statements. We have also seen how we can create and delete tables and columns. Now, we\u2019re going to learn a little bit about how to use the Like operator with wildcards to find very specific Read More >","og_url":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2018-04-06T15:10:49+00:00","article_modified_time":"2023-06-12T14:33:39+00:00","author":"Christopher Maiorana","twitter_card":"summary_large_image","twitter_creator":"@InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"Christopher Maiorana","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/"},"author":{"name":"Christopher Maiorana","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/c6922c56c84e17079fd558e07b7ef72f"},"headline":"How to Use &#8220;Like&#8221; in SQL","datePublished":"2018-04-06T15:10:49+00:00","dateModified":"2023-06-12T14:33:39+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/"},"wordCount":358,"commentCount":0,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"articleSection":["Working with Databases"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/","url":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/","name":"How to Use \"Like\" in SQL | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2018-04-06T15:10:49+00:00","dateModified":"2023-06-12T14:33:39+00:00","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/how-to-use-like-in-sql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to Use &#8220;Like&#8221; in SQL"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/c6922c56c84e17079fd558e07b7ef72f","name":"Christopher Maiorana","description":"Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog.","sameAs":["https:\/\/www.linkedin.com\/in\/chris-m-4623144b\/"],"url":"https:\/\/www.inmotionhosting.com\/support\/author\/christopherm\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":null,"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/4465","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=4465"}],"version-history":[{"count":4,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/4465\/revisions"}],"predecessor-version":[{"id":105113,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/4465\/revisions\/105113"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=4465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=4465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=4465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}