Saturday, March 11, 2017

SQL SELECT

At times, database users might need to retrieve data from a table. Depending on the requirements, they might need to extract either all or only selected columns or rows from a table. Users can retrieve the required data from the database using the SELECT statement. It is used to access and retrieve the data from a table in the database.

To select all the columns (*) asterisk is used, and to select some column(s) then those column(s) name must be specified in the SQL SELECT statement.




The result of SELECT is returned in a table-like structure called a result-set.

Syntax of SELECT:
           
      SELECT [ALL | DISTINCT] select_column_list
      [INTO [new_table_name]]
      FROM {TABLE_NAME | VIEW_NAME}
      [CLAUSES];

[] = Optional code


ALL is represented with an (*) asterisk symbol and displays all the columns of the table.

DISTINCT specifies that only the unique rows should appear in the result set.

select_column_list is the list of columns for which the data is to be listed.

INTO creates a new table and inserts the resulting rows from the result-set into it.

new_table_name is the name of the new table to be created.

FROM specifies the location from where the data is retrieved. Either from a table or from a view.

CLAUSE(S) specifies the search conditions for the rows returned by the query. It may include following clauses:

·         WHERE clause
·         GROUP BY clause
·         HAVING clause
·         ORDER BY clause

Share This
Previous Post
Next Post

TekGrabs, established in 2017, is in the business of sharing Information. It provides news, articles and photos about the different technologies, inventions in different domains. Provides information on programming and databases.

0 comments: