Loading video...
SQL Command: SELECT
- The
SELECTcommand is used to retrieve rows from a database whose data match specified criteria. ASELECTcommand has the following basic syntax:SELECT col1Name, col2Name FROM tblName;
- The results of a
SELECTquery are returned in tabular format with columns ordered by how they are listed in the query. - To specify the retrieval of all columns from a table, the wildcard character,
'*', can be used in place of the list of column names.- Note: the columns of the data returned are ordered according to the order of the columns in the table when using the wildcard character.
WHEREclauses can be used to refine the results of a query. A row will be returned if the expression specified in aWHEREclause, known as a where condition, evaluatesTRUEfor that row.- A
SELECTquery with aWHEREclause has the following syntax:SELECT * FROM items WHERE itemID=1001;
- A where condition can contain both logical and comparison operators:
- Logical:
OR,AND,NOT - Comparison:
=,!=,>,>=,<,<=
- Logical:
- When specifying string literals in where conditions, strings should be enclosed in quotation marks (single or
double).
- Note: be sure to properly escape quotation marks
- An
ORDER BYclause can be added to aSELECTquery to specify how the rows of data retrieved should be ordered. ASELECTquery containing anORDER BYclause has the following syntax:SELECT * FROM items ORDER BY price;
- The default sort order is ascending. Descending order can be specified with the
DESCkeyword:SELECT * FROM items ORDER BY price DESC;
- An
ORDER BYclause can specify multiple columns to order the rows by:SELECT * FROM items ORDER BY imageFileExt, price;
- Additional Resources:
SQL Command: SELECT
Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.
- Intro
- Lesson Overview
- SELECT Command
- SELECT Command: Definition and Syntax
- Results of a SELECT Query
- To Specify the Retrieval of All Columns from a Table
- Example: SELECT Command
- WHERE Clause
- WHERE Clause
- A SELECT Query with WHERE Clause has the Following Syntax
- A Where Condition can Contain both Logical and Comparison Operators
- Literal Values
- ORDER BY Clause
- ORDER BY Clause & SELECT Query
- Ascending and Descending Order
- An ORDER BY Clause can Specify Multiple Columns to Order the Rows by
- Example: SELECT Query with WHERE and ORDER BY Clause
- Homework Challenge
- Homework Challenge (cont.)

































Start Learning Now
Our free lessons will get you started (Flash® 10 required).
Sign up for Educator.comGet immediate access to our entire library.
Features Overview