SQL SELECT Tutorial

SQL Tutorial: SELECT Statement with Pictures

Discover the intricacies of SQL, including the SELECT statement's role in data retrieval from tables. Learn how this specific command can be applied in real-world contexts, such as managing player data in a basketball league.

Key Insights

  • The SELECT statement is the primary command used when querying data from a table in SQL.
  • This command allows users to specify which columns or data they wish to extract from a table.
  • The syntax for this statement is expressed as: SELECT * FROM table ;
  • For example, in a basketball league record-keeping scenario, the SELECT statement can be used to retrieve player and team data.
  • After formulating and entering the query, the result displays the specified player and team columns from the Stats table.
  • Understanding the SELECT statement and its proper utilization is critical for careers and classes centered on database management and data analysis.

How SELECT Works

  • Specifies Columns

    First input in any query — picks which columns of data to retrieve.

  • Use * for All Columns

    SELECT * FROM table; returns every column.

  • Multiple Columns

    Comma-separated: SELECT player, team FROM stats;

  • End with Semicolon

    Every query ends with a semicolon (;) to mark completion.

SELECT Statement

  • The SELECT statement is our first input whenever we write a query to retrieve data from a table.

  • This statement specifies which columns or data we want to retrieve from our table.

  • Syntax: SELECT * FROM table ;

Example

Let’s say we have a basketball league and we keep records of each player, which team they are on, and their basic statistics.

Stats Table

If we wanted to use a SQL query to retrieve the player and team of each player, we would write the following:

SQL Bootcamp: Live & Hands-on, In NYC or Online, Learn From Experts, Free Retake, Small Class Sizes,  1-on-1 Bonus Training. Named a Top Bootcamp by Forbes, Fortune, & Time Out. Noble Desktop. Learn More.

SQL Select

We are saying that we’d like to retrieve the player and team columns from the Stats table. Once we hit ENTER and run, our result should be as follows:

SQL SELECT Result

Learn more in these courses

How to Learn SQL

Master SQL with hands-on training. SQL is one of the most in-demand programming languages and is used across a variety of professions.

Yelp Facebook LinkedIn YouTube Twitter Instagram