{"id":4792,"date":"2012-05-28T11:52:37","date_gmt":"2012-05-28T11:52:37","guid":{"rendered":"http:\/\/phpcodez.com\/?p=4792"},"modified":"2012-05-28T11:52:37","modified_gmt":"2012-05-28T11:52:37","slug":"sql-like","status":"publish","type":"post","link":"http:\/\/phpcodez.com\/sql-like\/","title":{"rendered":"SQL LIKE"},"content":{"rendered":"<p>It searchs for a specified pattern in a column<\/p>\n<p><strong>SQL LIKE Syntax<\/strong><\/p>\n<p>SELECT * FROM table_name WHERE column_name LIKE pattern<\/p>\n<p>The &#8220;%&#8221; sign can be used to define wildcards (missing letters in the pattern) both before and after the pattern.<\/p>\n<p>\u2018%ab \u2018 &#8211; It will return data that end with the letter \u2018ab\u2019<br \/>\n\u2018ab%\u2019 &#8211; It returns the data that starts with \u2018ab\u2019<br \/>\n\u2018ab\u2019 &#8211; its similar to =<br \/>\n\u2018%ab%\u2019 &#8211; it returns the data that has the value \u2018ab\u2019 in it<\/p>\n<p><strong>MySQL Table &#8211; users<\/strong><\/p>\n<p>+&#8212;-+&#8212;&#8212;+<br \/>\n| id | name |<br \/>\n+&#8212;-+&#8212;&#8212;+<br \/>\n| \u00a01 | PHP \u00a0|<br \/>\n| \u00a02 | JS \u00a0\u00a0|<br \/>\n| \u00a03 | HTML |<br \/>\n| \u00a05 | ASP \u00a0|<br \/>\n+&#8212;-+&#8212;&#8212;+<\/p>\n<p><strong>Example<\/strong><\/p>\n<p>mysql&gt; select * from users WHERE name LIKE &#8216;%HP&#8217;;<br \/>\n+&#8212;-+&#8212;&#8212;+<br \/>\n| id | name |<br \/>\n+&#8212;-+&#8212;&#8212;+<br \/>\n| \u00a01 | PHP \u00a0|<br \/>\n+&#8212;-+&#8212;&#8212;+<br \/>\n1 row in set (0.00 sec)<\/p>\n<p>mysql&gt; select * from users WHERE name LIKE &#8216;HT%&#8217;;<br \/>\n+&#8212;-+&#8212;&#8212;+<br \/>\n| id | name |<br \/>\n+&#8212;-+&#8212;&#8212;+<br \/>\n| \u00a03 | HTML |<br \/>\n+&#8212;-+&#8212;&#8212;+<br \/>\n1 row in set (0.00 sec)<\/p>\n<p>mysql&gt; select * from users WHERE name LIKE &#8216;HT%&#8217;;<br \/>\n+&#8212;-+&#8212;&#8212;+<br \/>\n| id | name |<br \/>\n+&#8212;-+&#8212;&#8212;+<br \/>\n| \u00a03 | HTML |<br \/>\n+&#8212;-+&#8212;&#8212;+<br \/>\n1 row in set (0.00 sec)<\/p>\n<p>mysql&gt; select * from users WHERE name LIKE &#8216;%p%&#8217;;<br \/>\n+&#8212;-+&#8212;&#8212;+<br \/>\n| id | name |<br \/>\n+&#8212;-+&#8212;&#8212;+<br \/>\n| \u00a01 | PHP \u00a0|<br \/>\n| \u00a05 | ASP \u00a0|<br \/>\n+&#8212;-+&#8212;&#8212;+<br \/>\n2 rows in set (0.00 sec)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It searchs for a specified pattern in a column SQL LIKE Syntax SELECT * FROM table_name WHERE column_name LIKE pattern The &#8220;%&#8221; sign can be used to define wildcards (missing letters in the pattern) both before and after the pattern. \u2018%ab \u2018 &#8211; It will return data that end with the letter \u2018ab\u2019 \u2018ab%\u2019 &#8211; &hellip; <a href=\"http:\/\/phpcodez.com\/sql-like\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">SQL LIKE<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[332,370,392,457,461],"class_list":["post-4792","post","type-post","status-publish","format-standard","hentry","category-sql","tag-mysql","tag-php","tag-query","tag-sql","tag-statement"],"_links":{"self":[{"href":"http:\/\/phpcodez.com\/wp-json\/wp\/v2\/posts\/4792","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/phpcodez.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/phpcodez.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/phpcodez.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/phpcodez.com\/wp-json\/wp\/v2\/comments?post=4792"}],"version-history":[{"count":0,"href":"http:\/\/phpcodez.com\/wp-json\/wp\/v2\/posts\/4792\/revisions"}],"wp:attachment":[{"href":"http:\/\/phpcodez.com\/wp-json\/wp\/v2\/media?parent=4792"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/phpcodez.com\/wp-json\/wp\/v2\/categories?post=4792"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/phpcodez.com\/wp-json\/wp\/v2\/tags?post=4792"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}