SQL SELECT – Selection of Columns From the Table – Basic Clause

SELECT clause is used to gain data from a table. This clause is followed by a list of columns, which we need to display. This clause must always be used in combination with clause FROM by which we state from which table we want the data to be selected. Ideally, we also add clause WHERE which helps us to limit the result based on some kind of a condition.

SQL SELECT Syntax

There are 2 basic options of how to get a list of fields from a table. The first option is to name the individual fields (columns) after the SELECT clause:

SELECT [Column 1], [Column 2]
FROM [Table];

or we use * symbol (asterisk) and request a complete list of columns (all):

SELECT *
FROM [Table];

It is needed to mention that the second option is not recommended since * has a negative effect on the performance of the query. We usually do not need to display all the columns. More displayed columns mean less performing queries (longer duration of the process).

Tip: Special form of use of this clause is combination with DISTINCT – displaying unique values.

Rate this post
Category: SQL Basics SQL Clauses

About Ing. Jan Zedníček - Data Engineer & Controlling

My name is Jan Zednicek, and I have been working as a freelance Data Engineer for roughly 10 years. During this time, I have been publishing case studies and technical guides on this website, targeting professionals, students, and enthusiasts interested in Data Engineering particularly on Microsoft technologies as well as corporate finance and reporting solutions. 🔥 If you found this article helpful, please share it or mention me on your website or Community forum

Leave a Reply

Your email address will not be published. Required fields are marked *