The SELECT statement

The basic operation in day-to-day database use is retrieval of information. This is done with SELECT. The basic syntax is as follows:

SELECT [elements] FROM [table] WHERE [condition]  

Here, elements can be a wildcard (for example, * to select everything), or the list of columns you want to retrieve. table is the table(s) from which you want to retrieve the information. The WHERE clause is optional, and if used, the query will only return the rows that fulfill the condition. For example, you can select the name, description, and price columns of all products below $100 (USD):

SELECT name,description,price FROM products WHERE price<100  

The WHERE clause can also use Boolean operators to make more complex conditions:

SELECT columnA FROM tableX WHERE columnE='employee' AND columnF=100;  

The preceding SQL statement will return the values in columnA from a table named tableX if the condition following the WHERE clause is satisfied; that is, columnE has a employee string value and columnF has the 100 value.