TOP

SQL-Lesson 2. Data selection (SELECT)

The first and foremost statement in SQL is SELECT. With its help, we can select the fields (columns) with data in the table that we need.


1. Selection of individual fields.

Run SQLSELECT Product FROM Sumproduct

We can see that our SQL query selected the Product column from the Sumproduct table.

2. Selection of several fields.

Suppose we need to choose the name and quantity of the sold product. To do this, we simply list the necessary fields separated by a comma:

Run SQLSELECT Product, Quantity FROM Sumproduct

3. Selection of all columns.

If we need to get the entire table with all the fields, then simply put an asterisk (*):

Run SQLSELECT * FROM Sumproduct

Congratulations, you have made your first SQL queries.

All statements in SQL are case-insensitive, so you can write them both in uppercase and lowercase (as a rule, it is customary to write them in uppercase to distinguish them from field and table names). Names of tables and fields are, on the contrary, case-sensitive and must be written exactly as in the database.