| |
5. Using LIKE.
| Employee Address Table |
| SSN |
FirstName |
LastName |
Address |
City |
State |
| 512687458 |
Joe |
Smith |
83 First Street |
Howard |
Ohio |
| 758420012 |
Mary |
Scott |
842 Vine Ave. |
Losantiville |
Ohio |
| 102254896 |
Sam |
Jones |
33 Elm St. |
Paris |
New York |
| 876512563 |
Sarah |
Ackerman |
440 U.S. 110 |
Upton |
Michigan |
Look at the EmployeeStatisticsTable, and say you wanted to see all
people whose last names started with "L"; try:
SELECT EMPLOYEEIDNO
FROM EMPLOYEEADDRESSTABLE
WHERE LASTNAME LIKE 'L%'
The percent sign (%) is used to represent any possible character
(number, letter, or punctuation) or set of characters that might
appear after the "L". To find those people with LastName's
ending in "L", use '%L', or if you wanted the "L"
in the middle of the word, try '%L%'. The '%' can be used for any
characters in the same position relative to the given characters. NOT
LIKE displays rows not fitting the given description.
Other possiblities of using LIKE, or any of these discussed conditionals,
are available, though it depends on what DBMS you are using; as
usual, consult a manual or your system manager or administrator for
the available features on your system, or just to make sure that what
you are trying to do is available and allowed. This disclaimer holds
for the features of SQL that will be discussed below. This section is
just to give you an idea of the possibilities of queries that can be
written in SQL.
Index
<< Prev
1
2
3
4
5
6
7
8
9
10
11
12
13
Next >>
|