Workshop

Team-Fly    

 
Sams Teach Yourself SQL in 24 Hours, Third Edition
By Ronald R. Plew, Ryan K. Stephens
Table of Contents
Hour  7.  Introduction to the Database Query


The following workshop is composed of a series of quiz questions and practical exercises. The quiz questions are designed to test your overall understanding of the current material. The practical exercises are intended to afford you the opportunity to apply the concepts discussed during the current hour, as well as build upon the knowledge acquired in previous hours of study. Please take time to complete the quiz questions and exercises before continuing. Refer to Appendix C,"Answers to Quizzes and Exercises," for answers.

Quiz

1:

Name the required parts for any SELECT statement.

2:

In the WHERE clause, are single quotation marks required for all the data?

3:

Under what part of the SQL language does the SELECT statement (database query) fall?

4:

Can multiple conditions be used in the WHERE clause?

5:

What is the purpose of the DISTINCT option?

Exercises

1:

Invoke MySQL on your computer. Using your learnsql database, enter the following SELECT statements at the mysql> command prompt. Determine whether the syntax is correct. If the syntax is incorrect, make corrections to the code as necessary? We are using the EMPLOYEE_TBL here.

  1.  SELECT EMP_ID, LAST_NAME, FIRST_NAME,  FROM EMPLOYEE_TBL; 
  2.  SELECT EMP_ID, LAST_NAME  ORDER BY EMPLOYEE_TBL FROM EMPLOYEE_TBL; 
  3.  SELECT EMP_ID, LAST_NAME, FIRST_NAME  FROM EMPLOYEE_TBL WHERE EMP_ID = '213764555' ORDER BY EMP_ID; 
  4.  SELECT EMP_ID SSN, LAST_NAME  FROM EMPLOYEE_TBL WHERE EMP_ID = '213764555' ORDER BY 1; 
  5.  SELECT EMP_ID, LAST_NAME, FIRST_NAME  FROM EMPLOYEE_TBL WHERE EMP_ID = '213764555' ORDER BY 3, 1, 2; 
2:

Does the following SELECT statement work?

 SELECT LAST_NAME, FIRST_NAME, PHONE  FROM EMPLOYEE_TBL WHERE EMP_ID = '333333333'; 
3:

Write a SELECT statement that returns the name and cost of each product from the PRODUCTS_TBL. Which product is the most expensive?

4:

Write a query that generates a list of all customers and their telephone numbers .


Team-Fly    
Top
 


Sams Teach Yourself SQL in 24 Hours
Sams Teach Yourself SQL in 24 Hours (5th Edition) (Sams Teach Yourself -- Hours)
ISBN: 0672335417
EAN: 2147483647
Year: 2002
Pages: 275

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net