{"id":3917,"date":"2025-06-06T20:15:32","date_gmt":"2025-06-06T20:15:32","guid":{"rendered":"https:\/\/w3buddy.com\/?post_type=cposts&#038;p=3917"},"modified":"2025-06-07T09:56:06","modified_gmt":"2025-06-07T09:56:06","slug":"sql-like-wildcards","status":"publish","type":"cposts","link":"https:\/\/w3buddy.com\/blog\/notes\/sql\/sql-like-wildcards\/","title":{"rendered":"SQL LIKE &amp; Wildcards"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <code>LIKE<\/code> operator is used to <strong>search for patterns<\/strong> in text. It works with <strong>wildcards<\/strong> to match partial strings.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd39 Wildcards You Can Use<\/h2>\n\n\n\n<figure class=\"wp-block-table has-small-font-size\"><table><thead><tr><th>Wildcard<\/th><th>Meaning<\/th><\/tr><\/thead><tbody><tr><td><code>%<\/code><\/td><td>Matches <strong>zero or more characters<\/strong><\/td><\/tr><tr><td><code>_<\/code><\/td><td>Matches <strong>exactly one character<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd39 Examples with LIKE<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code><code>-- Starts with 'A'\nSELECT * FROM employees WHERE name LIKE 'A%';\n\n-- Ends with 'n'\nSELECT * FROM employees WHERE name LIKE '%n';\n\n-- Contains 'ar'\nSELECT * FROM employees WHERE name LIKE '%ar%';\n\n-- Second letter is 'e'\nSELECT * FROM employees WHERE name LIKE '_e%';\n\n-- 5-letter names only\nSELECT * FROM employees WHERE name LIKE '_____';<\/code><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd39 Case Sensitivity<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>MySQL<\/strong>: <code>LIKE<\/code> is <strong>case-insensitive<\/strong> by default (depends on collation)<\/li>\n\n\n\n<li><strong>PostgreSQL \/ SQL Server \/ Oracle<\/strong>: Usually <strong>case-sensitive<\/strong>\n<ul class=\"wp-block-list\">\n<li>Use <code>ILIKE<\/code> in PostgreSQL for case-insensitive match<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83e\udde0 Quick Recap<\/h2>\n\n\n\n<figure class=\"wp-block-table has-small-font-size\"><table><thead><tr><th>Pattern<\/th><th>Matches Example<\/th><\/tr><\/thead><tbody><tr><td><code>'J%'<\/code><\/td><td>John, Jack, Jenny<\/td><\/tr><tr><td><code>'%son'<\/code><\/td><td>Jason, Nelson<\/td><\/tr><tr><td><code>'__a%'<\/code><\/td><td>Anna, Sara, Mark<\/td><\/tr><tr><td><code>'_____'<\/code><\/td><td>Any 5-letter name<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u2705 Great for flexible searches like names, emails, and codes<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The LIKE operator is used to search for patterns in text. It works with wildcards to match partial strings. \ud83d\udd39 Wildcards You Can Use Wildcard Meaning % Matches zero or more characters _ Matches exactly one character \ud83d\udd39 Examples with LIKE \ud83d\udd39 Case Sensitivity \ud83e\udde0 Quick Recap Pattern Matches Example &#8216;J%&#8217; John, Jack, Jenny &#8216;%son&#8217; [&hellip;]<\/p>\n","protected":false},"template":"","meta":{"googlesitekit_rrm_CAowu461DA:productID":""},"categories":[952,979],"class_list":["post-3917","cposts","type-cposts","status-publish","hentry","category-notes","category-sql"],"_links":{"self":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/cposts\/3917","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/cposts"}],"about":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/types\/cposts"}],"wp:attachment":[{"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/media?parent=3917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/w3buddy.com\/blog\/wp-json\/wp\/v2\/categories?post=3917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}