Character Strings and Dates


Character strings and date values are enclosed with single quotation marks.
Character values are case-sensitive and date values are format-sensitive.
The default date display format is DD-MON-RR.


    SELECT last_name, job_id, department_id 
    FROM employees 
    WHERE last_name = 'Whalen' ;

    SELECT last_name
    FROM employees
    WHERE hire_date = '17-FEB-96' ;

Character strings and dates in the WHERE clause must be enclosed with single quotation marks ('').
Number constants, however, should not be enclosed with single quotation marks.

All character searches are case-sensitive.
Oracle databases store dates in an internal numeric format, representing the century, year, month,
day, hours, minutes,and seconds.

Comparison Operators

Comparison operators are used in conditions that compare one expression to another value or
expression. They are used in the WHERE clause in the following format:

Syntax

... WHERE expr operator value

Example
... WHERE hire_date = '01-JAN-95'
... WHERE salary >= 6000
... WHERE last_name = 'Smith'
An alias cannot be used in the WHERE clause.
Note: The symbols != and ^= can also represent the not equal to condition.

Using Comparison Operators


                                Operator                                                    Meaning

                                  =                                                             Equal to
                                  >                                                             Greater than
                                  >=                                                           Greater than or equal to
                                  <                                                             Less than
                                  <=                                                           Less than or equal to
                                  <>                                                           Not equal to
                                  BETWEEN   ...AND...                               Between two values (inclusive)
                                  IN(set)                                                     Match any of a list of values
                                  LIKE                                                       Match a character pattern
                                  IS NULL                                                  Is a null value

               SELECT last_name, salary
               FROM employees
               WHERE salary <= 3000 ;





In the example, the SELECT statement retrieves the last name and salary from the EMPLOYEES
table for any employee whose salary is less than or equal to 3,000. Note that there is an explicit
value supplied to the WHERE clause. The explicit value of 3000 is compared to the salary value in
the SALARY column of the EMPLOYEES table.

No comments:

Post a Comment