Episode 1 – Start with SELECT FROM

 

Writing SQLite reports using SELECT FROM

Writing SQLite reports properly requires a specific format and order of operations in which the clauses/commands are used.  All SQL reports, in standard order, start with the ‘SELECT’ clause and get more in-depth from there.

The SELECT clause is used to select/choose data from a table and/or database.

After specifying the data being selected, the engine must understand where to find the data.

The FROM clause is used to tell the engine which table(s) we are selecting data from.

When the data is returned, it is formatted as a table. This is also referred to as a result set.


Refer to the video content here for live examples of SQL syntax, queries and results.


When using SELECT, an asterisk in the select statement is used to return ALL columns and rows in the result set.  This is a great way to start practicing simpler SQL statements but will not be the most efficient route when writing more complex queries.

SELECT statement that includes ALL columns from the Computers table:

SELECT *
FROM Computers

The computers table has 76 columns in it so for size purposes, a picture of the result set has been left out.

Tip: A column may also be referred to as a field.

To reduce the number of columns in a result set, script only the necessary columns in your SELECT statement and separate each column with a comma. Be sure the very last column in the SELECT statement does not have any punctuation after it.

SELECT statement that includes ComputerId, Name and OSName columns from the Computers table:

SELECT ComputerId,
Name,
OSName
FROM Computers

Result Set:

*In the video reference, four columns were included in the example query run in PDQ Inventory but the formatting is the same using commas to separate the columns in the syntax*

Your email address will not be published.

Your Name

This site uses Akismet to reduce spam. Learn how your comment data is processed.