Collection Contents Index Selecting columns from a table Comparing dates in queries pdf/chap12.pdf

First Guide to SQL Anywhere Studio
   PART 3. Basic SQL
     CHAPTER 12. Selecting Data from Database Tables       

Selecting rows from a table


Sometimes you will not want to see information on all the employees in the employee table. Adding a WHERE clause to the SELECT statement allows only some rows to be selected from a table.

For example, suppose you would like to look at the employees with first name John.

  List all employees named John:
  1. Type the following:

    SELECT *
    FROM employee
    WHERE emp_fname = 'John'

emp_id

manager_id

emp_fname

emp_lname

dept_id

318

1576

John

Crow

400

862

501

John

Sheffield

100

1483

1293

John

Letiecq

300

Apostrophes and case-sensitivity 

Again, you can combine what you have learned:

SELECT emp_fname, emp_lname, birth_date
FROM employee
WHERE emp_fname = 'John'
ORDER BY birth_date

Notes 


Collection Contents Index Selecting columns from a table Comparing dates in queries pdf/chap12.pdf