The SQL SELECT Statement:

The SELECT statement is used to select data from a table. The result is stored in a result table (called the result-set).

Syntax:

SELECT column_name(s) FROM table_name

Note:

SQL statements are not case sensitive.” SELECT” is the same as “select”.

Example:

Below is an example of a table called ‘UserInfo’

LastName FirstName Address City
Hansen John Timoteivn 10 Sandnes
Svendson Sharon Borgvn 23 Sandnes
Pettersen Kari Storgt 20 Stavanger

Query:

SELECT LastName FROM UserInfo

The Result: It will result the specified column.

LastName
Hansen
Svendson
Pettersen

 Select All Columns:

To select all columns from the “UserInfo” table, use a ‘ * ‘  symbol instead of name of columns, like this:

Syntax:

SELECT * FROM table name

Query:

SELECT * FROM UserInfo

The Result: It will result the table with all columns and rows.

LastName FirstName Address City
Hansen John Timoteivn 10 Sandnes
Svendson Sharon Borgvn 23 Sandnes
Pettersen Kari Storgt 20 Stavanger

Leave a Reply

Your email address will not be published. Required fields are marked *