Database Reference
In-Depth Information
Figure 6.14
Select all columns from STUDENT table.
Figure 6.15
Select StudentID and FacultyID for students with last name Cox.
clause, the data type of the LastName column is the character string data type, so the last name
Cox should be enclosed with single quotation marks. In SQL Database, single quotes are also
used for DATETIME values. For numerical values, no quotation mark is needed. Although SQL
statements are not case sensitive, a character string enclosed in the single quotation marks is case
sensitive. he search will match exactly what is enclosed in the single quotes. Figure 6.15 shows
the query result from the above SQL statement.
In a WHERE clause, search conditions can be deined by operators. here are three types of
operators: logical operator, comparison operator, and arithmetic operator. In the following section,
you will learn how to use the operators to deine search conditions.
6.2.2 Logical Operators
Logical operators are commonly used to combine multiple search conditions or set limits for val-
ues to be selected (Table 6.1).
To see how to use these logical operators, consider the following examples. In Figure 6.16, the
SQL statement selects the irst names and last names of students who have the last name Cox or
the last name Diaz.
he above query selects three rows. Two rows match the condition LastName = 'Cox' and one
row matches the condition LastName = 'Diaz'. As an example of using the AND operator, let us
select the student who has the irst name Liz and last name Cox. he SQL statement and the query
result are illustrated in Figure 6.17.
Search WWH ::




Custom Search