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

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

My name is Jan Zedníček and I have been working as a freelancer for many companies for more than 10 years. I used to work as a financial controller, analyst and manager at many different companies in field of banking and manufacturing. When I am not at work, I like playing volleyball, chess, doing a workout in the gym.

🔥 If you found this article helpful, please share it or mention me on your website

Leave a Reply

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