Building Simple Queries |
||||
Writing SELECT StatementsWhen Sheila writes a basic query, two mandatory clauses in the SELECT statement syntax are required: a SELECT clause and a FROM clause. The SELECT statement syntax is displayed. The SELECT clause specifies the columns that you want to display. The FROM clause specifies the tables that contain those columns. Syntax SELECT [DISTINCT] * | column [alias], ... FROM table; Example
SELECT [DISTINCT] * | column [alias], ... FROM table condition : The condition consists of three components:
select * from employees; You can use the projection capability of SQL to choose the columns in a table that you want to retrieve. You can retrieve selected columns or all columns from a table. You can use the selection capability of SQL to choose the rows that you want to retrieve from a table. You can specify various criteria to select the rows that you want to see. You can restrict the number of rows that are retrieved from the database by using a WHERE clause in a SQL statement. By inserting a WHERE clause into a SQL statement, you can specify a condition that must be met, and only the rows that meet the condition are returned. When using a WHERE clause:
|