Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære The SELECT Statement | Retrieving Data with SELECT
SQL Fundamentals: An Introductory Course

bookThe SELECT Statement

Stryg for at vise menuen

When you want to retrieve information from a database, you use the SELECT statement. This is the most fundamental SQL command for querying data. The SELECT statement allows you to specify exactly which data you want to see from one or more tables in your database. Whether you need all the data or just a few specific pieces of information, SELECT is your main tool for asking questions and getting answers from your tables.

1
SELECT * FROM students;
copy

Often, you do not need every column from a table. You can tailor your results by specifying which columns you want to see. To do this, list the column names you are interested in after the SELECT keyword, separated by commas. For example, if you only want to see the first names and enrollment years of students, you can write a query that selects just those columns.

1
SELECT first_name, enrollment_year FROM students;
copy

Sometimes, you may want to make your output easier to read or better reflect the meaning of your data by renaming columns in your query results. You can do this using a column alias with the AS keyword. An alias gives a temporary name to a column in your result set, making it more descriptive or suitable for your needs.

1
SELECT first_name AS "Student Name", enrollment_year AS "Year Enrolled" FROM students;
copy
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 1

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

Sektion 2. Kapitel 1
some-alt