Databaselab 5
Databaselab 5
ENGINEERING
LAB ASSESSMENT:
Ability to Conduct
Experiment
Data presentation
Experimental results
Conclusion
Objectives:
To understand SQL wild cards and the operators used in SQL.
SQL Wildcards:
SQL wildcards can be used when searching for data in a database
SQL wildcards can substitute for one or more characters when searching for data in a
database.
SQL wildcards must be used with the SQL LIKE operator
With SQL, the following wildcards can be used:
Next, we want to select the persons living in a city that contains the pattern "nes" from the
"Persons" table.
We use the following SELECT statement:
Next, we want to select the persons with a last name that do not start with "b" or "s" or "p"
from the "Persons" table.
We use the following SELECT statement:
SQL IN Operator:
The IN operator allows you to specify multiple values in a WHERE clause.
SQL IN Syntax:
IN Operator Example:
The "Persons" table:
Now we want to select the persons with a last name equal to "Hansen" or "Pettersen" from
the table above.
We use the following SELECT statement:
Example 2:
To display the persons outside the range in the previous example, use NOT BETWEEN: