SELECT is an SQL command for retrieving data from a (relational) database. The simplest SELECT statement is this:

SELECT * FROM example

The statement above tells the database to return all data in the table called example, with the rows in no particular order. To limit the amount of data that is returned you can specify which fields in the table to return, and you can set conditions on the rows that are returned with a WHERE clause.

SELECT nickname, firstname, lastname FROM example WHERE nickname='nate'

The statement above will return all rows that have the value 'nate' in the field nickname. Each returned row only contains data from the fields nickname, firstname and lastname.

SELECT nickname, firstname, lastname FROM example ORDER BY lastname

If you include the ORDER BY clause, then the rows will be sorted by the field(s) in the ORDER BY clause. If you add DESC after the field name(s), then the rows are sorted in descending order.

You can do much more with SELECT statements, such as selecting from more than one table (called joining), but unfortunately the syntax sometimes varies depending on which database server you use.

See LIKE for information on how to perform pattern matching.