Basic SQL Functions – Part 1: SELECT and FROM Statements

By: Tyler Dougherty

June 3, 2020

The select and from clauses are two of the most used statements in Structured Query Language, or SQL for short. We primarily use SQL to create views on the fly. Understanding what a view is will help to better understand the purpose of these statements. A view is a subset of records and/or a subset of columns of a larger table. For example, if we had a transactional table that recorded all characteristics of a transaction, such as price, quantity sold, date sold, customer, location sold, etc. but we are only interested in seeing the customer who made the purchase and the total amount in dollars we would use these two statements to achieve this.

There are two simple ways of selecting which columns to be presented in a view. Using select * will simply give you a view that contains every column in the table you are choosing from. This can be helpful when looking at a table for the first time and is used by many to get a quick visual of what information the table contains. We can also use select with specific column names to only look at a subset of columns we are interested in. For the example above with the transactional table we can use select customer_id, total_due to get only the information about the customer and the amount in dollars they spent.

The from portion of the code only defines from which table you would like to see this information from. Databases or datamarts can have several tables they may have relationships to each other. Each table in the database will have a unique name exactly for this reason. Below you will see an example of how to execute a simple select statement in SQL Server Management Studio.

Click here for Part 2: WHERE Statement


Subscribe to QueBIT Notifications

Can’t find what you’re looking for? →

    Contact Help Desk

    This form collects your contact information so that we can correspond with you. For more information on how we are committed to protecting and respecting your privacy, please review our Privacy Policy.

    I consent to QueBIT collecting my contact information.