The SELECT statement is at the heart of most SQL queries. It defines what result set should be returned by the query, and is almost always used in conjunction with the FROM clause, which defines what part(s) of the database should be queried.
SELECT [DISTINCT] [column1] [, [column2] ... ]
FROM [table]
[ WHERE condition ]
[ GROUP BY [column1] [, [column2] ... ]
[ HAVING [column1] [, [column2] ... ]
[ ORDER BY ASC | DESC ]
SELECT determines which columns' data to return and in which order FROM a given table (given that they match the other requirements in your query specifically - where and having filters and joins).
SELECT Name, SerialNumber
FROM ArmyInfo
will only return results from the Name
and Serial Number
columns, but not from the column called Rank
, for example
SELECT *
FROM ArmyInfo
indicates that all columns will be returned. However, please note that it is poor practice to SELECT *
as you are literally returning all columns of a table.