SELECT and FROM

Each clause in a SELECT query performs the following functions:

  • SELECT – specifies the attributes to be returned by the query

  • FROM – specifies the table(s) from which the data will be retrieved

  • WHERE – filters the rows of data based on provided criteria

  • GROUP BY – groups the rows of data into collections based on sharing the same values in one or more attributes

  • HAVING – filters the groups formed in the GROUP BY clause based on provided criteria

  • ORDER BY – sorts the final query result rows in ascending or descending order based on the values of one or more attributes

 

 

  • SQL commands can be grouped together on a single line

    • Complex command sequences are best shown on separate lines, with space between the SQL command and the command’s components

  • SELECT is a SQL command that yields the values of all rows or a subset of rows in a table

    • The SELECT statement is used to retrieve data from tables

  • FROM is a SQL clause that specifies the table or tables from which the data is to be retrieved

    • The FROM clause of the query specifies the table or tables from which the data is to be retrieved

      • Only columns in the table specified in the FROM clause are available throughout the rest of the query

    • The table in the FROM clause forms the basis for the rest of the query

      • It defines the data that will be available to the remainder of the query

    • Multiple tables must be combined using a type of JOIN operation

Syntax

SELECT   columnlist

 FROM   tablelist;

 

Â