Enter your Sign-on user name and password.

Forgot password?
  • Follow us on:
Loading video...

Start Learning Now

Our free lessons will get you started (Flash® 10 required).
Get immediate access to our entire library.

Sign up for Educator.com

Features Overview

  • Get on-demand access to our complete library
  • Search and jump to exactly what you need to learn
  • Track your progress
  • Download practice and lesson files
  • *Ask questions and get answers from our community & instructors

SQL Command: SELECT

  • The SELECT command is used to retrieve rows from a database whose data match specified criteria. A SELECT command has the following basic syntax:
    SELECT col1Name, col2Name FROM tblName;
  • The results of a SELECT query 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.
  • WHERE clauses can be used to refine the results of a query. A row will be returned if the expression specified in a WHERE clause, known as a where condition, evaluates TRUE for that row.
  • A SELECT query with a WHERE clause 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: =, !=, >, >=, <, <=
  • 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 BY clause can be added to a SELECT query to specify how the rows of data retrieved should be ordered. A SELECT query containing an ORDER BY clause has the following syntax:
    SELECT * FROM items ORDER BY price;
  • The default sort order is ascending. Descending order can be specified with the DESC keyword:
    SELECT * FROM items ORDER BY price DESC;
  • An ORDER BY clause 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.

Advanced PHP Training with MySQL