Select Statement
The SELECT statement is used to retrieve the rows from one or more tables in a database.
Selecting All Columns
To select all the rows of a table, use the asterisk (*).
Syntax
SELECT <query-parameters> FROM <table-name>;
Example #1
SELECT * FROM Companies;
| Name | Type | Founded | HQ |
|---|---|---|---|
| Walmart | Retail | 1962 | United States |
| Disney | Entertainment | 1923 | United States |
| PayPal | Finance | 1998 | United States |
| Blackberry | Technology | 1984 | Canada |
Tip: If you have a lot of rows use
ctrl-corcmd-cto escape from viewing more rows.
Selecting Specific Columns
Specific columns can be retrieved from a table too.
Syntax
SELECT <column-name> FROM <table-name>;
Example #2
SELECT name, founded, hq FROM Companies;
| Name | Founded | HQ |
|---|---|---|
| Walmart | 1962 | United States |
| Disney | 1923 | United States |
| PayPal | 1998 | United States |
| Blackberry | 1984 | Canada |