SELECT
SELECT

The SELECT keyword tells ORACLE which columns you want

AN EXAMPLE

SELECT Name, Age FROM Workers WHERE Department = 'Transportation' ORDER BY Name

  • The SELECT keyword tells ORACLE which columns you want (Name, Age, Department).
  • The FROM tells ORACLE the names of the table those columns are in (Workers).
  • The WHERE keyword tells ORACLE what qualification you'd like to put on
    the information it is selecting for you. In our example ORACLE cheks each row and skipped over those without the word "Transportation" in their Department column. It will return records with Name and Age of the workers from the "Transportation" Department
  • The ORDER BY tells ORACLE that you want the information it returns sorted in order you specify.

SELECT * FROM Workers WHERE Age > 25 AND Department='Knowledgebase' Return records of mature Workers in the Knowledgebase department with all fields in each record
SELECT Skills.Name, Tel
FROM Workers, Skills
WHERE Skills.Speciality='Natural Language Processing' AND Workers.Department='Knowledgebase' AND Skills.Name=Workers.Name
This query will hit two database tables: Skills and Workers. It will return names and phone numbers of workers from the Knowledgebase department with the Natural Language Processing speciality
Select COUNT(*) FROM Workers This query returns a total number of records in the Workers table.

EXERCISE:

Write SQL SELECT statement for the table created in the following example CREATE A TABLE


Back to SQL statements.