By Hemanta Sundaray on 2022-12-18
SELECT statements are used to fetch data from a database. In the statement below, SELECT returns all data in the name column of the students table.
SELECT name FROM students;
Suppose you are only interested in two columns:
name & age. You can select individual columns by their names (separated by comma):
SELECT name, age FROM students;
To make it easier to read, we have moved
FROM to another line.
Note that line breaks don't mean anything specific in SQL. We could write the entire query in one line, and it would run just fine.
You can also query data from all columns in a table with
SELECT * FROM students;
* is a special wildcard character that we have been using. It allows you to select every column in a table without having to name each one individually. Here, the result set contains every column in the celebs table. SELECT statements always return a new table called the result set.