Interactive Online SQL Training
The select statement is used to query the database and retrieve selected data that match the criteria that you specify. Here is the format of a simple select statement:
The column names that follow the select keyword determine which columns will be returned in the results. You can select as many column names that you'd like, or you can use a "*" to select all columns.
The table name that follows the keyword from specifies the table that will be queried to retrieve the desired results.
The where clause (optional) specifies which data values or rows will be returned or displayed, based on the criteria described after the keyword where.
Conditional selections used in the where clause:
The LIKE pattern matching operator can also be used in the conditional selection of the where clause. Like is a very powerful operator that allows you to select only rows that are "like" what you specify. The percent sign "%" can be used as a wild card to match any possible character that might appear before or after the characters specified. For example:
This SQL statement will match any first names that start with 'Er'. Strings must be in single quotes.
Or you can specify,
This statement will match any last names that end in a 's'.
This will only select rows where the first name equals 'Eric' exactly.
Enter the following sample select statements in the SQL Interpreter Form at the bottom of this page. Before you press "submit", write down your expected results. Press "submit", and compare the results.
Select statement exercises
Enter select statements to: