A SELECT statement in SQL returns a result set of records from one or more tables.
The general format is:
SELECT */ column1, column2,...
FROM tablename
[WHERE condition]
[GROUP BY column1, column2.... ]
[HAVING groupcondition ]
[ORDER BY column1 [DESC], column2 [DESC]... ]
The SELECT statement has many optional clauses:
WHERE specifies which rows to retrieve.
GROUP BY groups rows sharing a property so that an aggregate function can be applied to each group.
HAVING selects among the groups defined by the GROUP BY clause.
ORDER BY specifies an order in which to return the rows.
AS provides an alias which can be used to temporarily rename tables or columns.
Example 1:
SELECT * FROM country;
Example 2:
SELECT countrycode, countryname FROM country;
Example 3:
SELECT * FROM country WHERE countrycode=34;