The SQL SELECT Statement
• The SELECT statement is used to select data from a database.
• The data returned is stored in a result table, called the result-set.
SELECT Syntax
SELECT column1, column2, ...
FROM table_name;
• Here, column1, column2, ... are the field names of the table you wa
to select data from. If you want to select all the fields available in th
table, use the following syntax:
SELECT * FROM table_name;
,Example 1.
SELECT Name, Address FROM Customers;
Example 2.
• The following SQL statement selects all the columns from the
"Customers" table:
SELECT * FROM Customers;
,• ADD RECORDS WITH SIMILAR ADDRESSES
, The SQL SELECT DISTINCT
Statement
• The SELECT DISTINCT statement is used to return only distinct
(different) values.
• Inside a table, a column often contains many duplicate values; and
sometimes you only want to list the different (distinct) values.
• SELECT DISTINCT Syntax
SELECT DISTINCT column1, column2, ...
FROM table_name;
Example 1
• SELECT DISTINCT salary FROM Customers;
• The SELECT statement is used to select data from a database.
• The data returned is stored in a result table, called the result-set.
SELECT Syntax
SELECT column1, column2, ...
FROM table_name;
• Here, column1, column2, ... are the field names of the table you wa
to select data from. If you want to select all the fields available in th
table, use the following syntax:
SELECT * FROM table_name;
,Example 1.
SELECT Name, Address FROM Customers;
Example 2.
• The following SQL statement selects all the columns from the
"Customers" table:
SELECT * FROM Customers;
,• ADD RECORDS WITH SIMILAR ADDRESSES
, The SQL SELECT DISTINCT
Statement
• The SELECT DISTINCT statement is used to return only distinct
(different) values.
• Inside a table, a column often contains many duplicate values; and
sometimes you only want to list the different (distinct) values.
• SELECT DISTINCT Syntax
SELECT DISTINCT column1, column2, ...
FROM table_name;
Example 1
• SELECT DISTINCT salary FROM Customers;