How to use the SQL SELECT Statement

How to use the SQL SELECT Statement


How to use the SQL SELECT Statement

Learn how to use the SQL SELECT Statement. This tutorial demonstrates how to write a SELECT query with an easy to follow example.

SQL Select Statement (and sample data):
https://www.techonthenet.com/sql/sele

SQL Tutorials:
https://www.techonthenet.com/sql/inde

Don’t forget to subscribe to our channel for more great SQL tutorials!

Visit us at: https://www.techonthenet.com
or follow us on:

Facebook: https://www.facebook.com/techonthenetcom
Twitter: https://twitter.com/tech_on_the_net
Pinterest: https://www.pinterest.com/techonthene


Content

0.02 -> The SELELCT statement (or commonly referred to as a "SELECT query")
4.08 -> is the most popular command in SQL
6.76 -> SELECT statements are used to retrieve records from your SQL database
12.04 -> The records retrieved are known as a result set
15.52 -> To illustrate how the SELECT statement works, let's look at an example
20.65 -> Here we have a table called customers containing the following data
26.86 -> We'll start our SELECT statement by entering the SELECT keyword
30.82 -> This lets the database know that we want to write a SELECT query and return a result set
36.92 -> You can either enter the columns as comma separated values
40.8 -> or you can use the * character to specify all columns
45.066 -> In this example, we want all columns to appear in the result set
49.1 -> so we will enter SELECT *
52.68 -> Next, we need to enter the FROM clause
55.58 -> The FROM clause lets the database know which tables we would like the data retrieved from
60.76 -> In this example, we'll enter customers as our table
64.64 -> Now the query knows to return all columns from the customers table
69.38 -> The WHERE clause is optional
72.16 -> It is used to specify conditions that must be met for the records to be selected and appear in the result set
78.66 -> If no conditions are provided, then all records will be selected
82.82 -> Since we want to return only those records where the favorite_website is TechOnTheNet.com
88.38 -> we will enter our WHERE clause as follows
92.29 -> The value TechOnTheNet.com must be enclosed in quotes since it is a string value
98.9 -> Finally, we can add an optional ORDER BY clause
102.66 -> The ORDER BY clause instructs the database to sort the records returned in the result set
108.22 -> based on the table columns provided
110.72 -> You can also append either the ASC or the DESC modifiers to the ORDER BY clause
117.72 -> Adding ASC will return the results in ascending order
122.46 -> Adding DESC will return them in descending order
128.58 -> In this example, we will sort our result set by the column last_name and add the ASC modifier
135.76 -> Now let's run our SELECT statement and see what results we get
141.19 -> Our query returns all columns from the customers table
144.52 -> where the favorite_website is equal to TechOnTheNet.com
148.2 -> and the result sets is sorted by last_name in ascending order
153.14 -> This covers a simple example of how to use the SQL SELECT statement
159.2 -> If you would like to see more SELECT examples
162.14 -> or would like to download the sample data we used for this tutorial
165.24 -> please visit our website at TechOnTheNet.com
168.46 -> You can also try the examples in our SQL editor on our website
172.34 -> Look for the "Try It" button next to each example
177.56 -> If you found her tutorial helpful, please leave a like on this video
181.92 -> and don't forget to subscribe to our YouTube channel for more great SQL tutorials

Source: https://www.youtube.com/watch?v=gbHXhXmACgI