-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlike.html
More file actions
78 lines (58 loc) · 3.3 KB
/
like.html
File metadata and controls
78 lines (58 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!-- SECCIÓN LIKE -->
<div id="like-section">
<div id="adsense-container" style="width: 350px; position: absolute; left: 0px;"></div>
<div class="inner-modal">
<div class="inner" style="padding: 0px;">
<h1>SQL LIKE Operator</h1>
<p>The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.</p>
<p>There are two wildcards often used in conjunction with the LIKE operator:</p>
<p>- The percent sign (%) represents zero, one, or multiple characters</p>
<p>- The underscore sign (_) represents one, single character</p>
<p>The percent sign and the underscore can also be used in combinations</p>
<h2>LIKE Syntax</h2>
<pre><code class="language-sql">SELECT column1, column2, ...
FROM table_name
WHERE column LIKE pattern;</code></pre>
<h2>Common LIKE Patterns</h2>
<pre><code class="language-sql">-- Finds any values that start with "a"
WHERE first_name LIKE 'a%';
-- Finds any values that end with "a"
WHERE first_name LIKE '%a';
-- Finds any values that have "or" in any position
WHERE first_name LIKE '%or%';
-- Finds any values that have "r" in the second position
WHERE first_name LIKE '_r%';
-- Finds any values that start with "a" and are at least 2 characters
WHERE first_name LIKE 'a_%';
-- Finds any values that start with "a" and are at least 3 characters
WHERE first_name LIKE 'a__%';
-- Finds any values that start with "a" and ends with "o"
WHERE first_name LIKE 'a%o';</code></pre>
<h2>SQL LIKE Examples</h2>
<p>The following SQL statement selects all patients with a first_name starting with "a":</p>
<pre><code class="language-sql">SELECT * FROM patients
WHERE first_name LIKE 'a%';</code></pre>
<p>The following SQL statement selects all patients with a first_name ending with "a":</p>
<pre><code class="language-sql">SELECT * FROM patients
WHERE first_name LIKE '%a';</code></pre>
<p>The following SQL statement selects all patients with a first_name that have "or" in any position:</p>
<pre><code class="language-sql">SELECT * FROM patients
WHERE first_name LIKE '%or%';</code></pre>
<p>The following SQL statement selects all patients with a first_name that have "r" in the second position:
</p>
<pre><code class="language-sql">SELECT * FROM patients
WHERE first_name LIKE '_r%';</code></pre>
<p>The following SQL statement selects all patients with a first_name that starts with "a" and are at least
3 characters in length:</p>
<pre><code class="language-sql">SELECT * FROM patients
WHERE first_name LIKE 'a__%';</code></pre>
<p>The following SQL statement selects all patients with a first_name that starts with "a" and ends with
"o":</p>
<pre><code class="language-sql">SELECT * FROM patients
WHERE first_name LIKE 'a%o';</code></pre>
<p>The following SQL statement selects all patients with a first_name that does NOT start with "a":</p>
<pre><code class="language-sql">SELECT * FROM patients
WHERE first_name NOT LIKE 'a%';</code></pre>
</div>
</div>
</div>