Write SELECT statements that retrieve all rows from a single table. The SELECT statement is a basic element of SQL. It is used to specify the data you want to retrieve from a specified database table or tables.
In it's most simple form, the SELECT statement will request the data in a single table.
Like all languages, SQL has a required syntax .
The following Tool Tip describes a simple SELECT statement's syntax:
SQL keywords, such as SELECT, can be upper, lower, or mixed case. However, the convention is to use all upper case. One or more column names can be specified in a SELECT statement.
If more than one name is specified, each must be separated by a comma. When the columns are later displayed, they will be displayed in the order they are specified in the argument list. The following SQL statement returns three fields from the BookTable.
SELECT ItemNo, Title, Author FROM BookTable
View the following image to see the results of this query.
If you want to get all the columns from a table, you do not have to specify all the column names in the argument list. You can use the asterisk ( * ) instead. The asterisk is like a wildcard character that means everything. For example:
SELECT * FROM BookTable
In the next lesson, you will learn how to use the WHERE clause to select specific rows from a database.