How to use the SQL select like parameter
A similar operation uses a WHERE clause to search a column of a particular pattern.
A similar operator
Similar operators are used to search for specified patterns in a column.
Like the SQL syntax
SELECT column_name (s) from
table_name
WHERE column_name like pattern
For example like Yun in the "person" table:
p_id |
LastName |
FirstName |
| Address
| City
1 |
Hansen |
Ola |
TIMOTEIVN 10 |
Sandnes |
2 |
Svendson |
Tove |
BORGVN 23 |
Sandnes |
3 |
Pettersen |
Kari |
STORGT 20 |
Stavanger |
Now, we want to select the people who live in a city and start with "S" shaped from the above table.
We use the following SELECT statement:
SELECT * from Persons
WHERE city like ' s% '
The "%" symbol can be used to define the pattern before and after the wildcard character (missing letter mode).
The result set looks like this:
p_id |
LastName |
FirstName |
| Address
| City
1 |
Hansen |
Ola |
TIMOTEIVN 10 |
Sandnes |
2 |
Svendson |
Tove |
BORGVN 23 |
Sandnes |
3 |
Pettersen |
Kari |
STORGT 20 |
Stavanger |
Next, we want to select people living in a city, the last "S" form from "person" seating.
We use the following SELECT statement:
SELECT * from Persons
WHERE city like '%s '
p_id |
LastName |
FirstName |
| Address
| City
1 |
Hansen |
Ola |
TIMOTEIVN 10 |
Sandnes |
2 |
Svendson |
Tove |
BORGVN 23 |
Sandnes |
Next, we want to choose people who live in a city that contains patterns of "tomato sterility virus" "People" seating.
We use the following SELECT statement:
SELECT * from Persons
WHERE city like '%tav% '
_id |
LastName |
FirstName |
| Address
| City
3 |
Pettersen |
Kari |
STORGT 20 |
Stavanger |
The
also has the potential to choose people living in a city that does not contain the model "tomato sterility virus" in the "People" table, by using not keywords.
We use the following SELECT statement:
select * from Persons WHERE city isn't like '%tav% '
_i D |
lastname |
firstname |
address |
city |
1 |
Hansen |
ola |
timoteivn ten |
sandnes |
2 |
svendson |
Tove |
borgvn |
sandnes |
Note: Reprint please indicate from Www.111cn.net/database/database.html