SQL clause is the specific part of a SQL statement which is used to perform various operations. It can be combined to create more complex queries to retrieve and manipulate data.
SELECT clause is used to retrieve/get data from table(s) in the database. It is often used with other clauses such as 'FROM', 'WHERE' and 'ORDER BY' etc. to specify table, filter, sort and manipulate data.
SELECT column_name(s) FROM table_name;
• Specify the column(s) name after the 'SELECT' keyword.
• Specify Asterisk (*) symbol to selects all columns from the table after the 'SELECT' keyword.
• Specify the table name after the 'FROM' keyword.
1. Let's assume we have a table named "[Product]".
2. Let's retrieve all columns and rows from the this table >> Run below SQL statement :
SELECT * FROM [Product];
2. Above statement will select all the data from the [Product] table.
That's it! You have successfully retrieved all data from [Product] table.
1. Suppose we want to retrieve only specific columns from the [Product] table.
2. Run below SQL statement :
SELECT [ProductID], [Name], [ProductNumber] FROM [Product];
3. Above statement will select only [ProductID], [Name] and [ProductNumber] columns from the [Product] table.
That's it! You have successfully selected [ProductID], [Name] and [ProductNumber] columns from [Product] table.
1. Suppose we want to retrieve only specific number of rows from the [Product] table.
2. Run below SQL statement :
SELECT TOP 3 * FROM [Product];
3. Above statement will select only top 3 rows from the [Product] table.
That's it! You have successfully retrieved top 3 rows from [Product] table.
The SELECT clause retrieves data from a database table.
The five major clauses of the SELECT command are SELECT, FROM, WHERE, GROUP BY, and ORDER BY.
The three types of SELECT queries are SELECT, SELECT DISTINCT, and SELECT INTO.
The FROM clause in the SELECT statement specifies the table or tables from which to retrieve data.