The Columns of a Query
The Columns of a Query

The Columns of a Query

Published at February 1, 2019by Jörg Brandeis

The following texts were partially or completely generated with the help of generative AI models.

The Columns of a Query

With the SELECT statement, we can request data from the tables of the database. The result of the SELECT statement is also a table, i.e. it consists of columns and rows. At first, you can think of it like an Excel spreadsheet. The simplest form of the SELECT statement looks like this:

SELECT * FROM <Quelltabelle>

All Columns of a Table

If we want to request all columns of the table, we can specify the asterisk * in the field list. The corresponding query for this:

SELECT * FROM <Quelltabelle>

With this, we can request the complete content of a table: * all columns and * all rows Let's try this out by querying the table TASKS in our data model. A data model is a model of the data to be described and processed within an application area (e.g. data of the production area, of accounting, or the entirety of company data) and their relationships to each other. In computer science, especially in the development of information systems, data models and the activities carried out to create them (data modeling) serve to define the structure for the data to be processed (in particular to be stored) in the systems... This table contains 1000 rows and many columns.

Individual Columns in the Field List

Often we don't need all columns, and sometimes superfluous columns are even a nuisance. In that case, we can name the required columns individually in the field list. To do this, the column names are listed separated by commas.

SELECT id, 
       title, 
       assignee, 
       due_date
  FROM tasks;   

<<= Previous Lesson | Back to Lesson | Next Topic ==>

More articles

New!
New!