Get Started: SQL SELECT Statement

In This Article, You Will Know About SQL SELECT.

SQL SELECT – Before moving ahead, let’s know a bit about SQL Syntax.

Table of Contents

SELECT Statement

The SELECT statement is used to select information from a database, such as a table.

The information returned is saved as a result-table also known as the result-set.

SELECT Syntax

SELECT column1, column2, …
FROM table_name;

Here columns 1, 2, … are the field/option names for the table that have to select information from. To select all fields that are available inside the table, use this syntax.

				
					SELECT * FROM table_name;
				
			

Database

Below is an example of a database table named “etable”.

Id

name

class

section_id

1

Alex

5

1

2

Rolex

6

2

3

Salex

7

2

4

Lelex

8

3

5

Kelex

9

5

SELECT Column

The following SQL statement selects the “name” and “class” columns from the “etable” table:

Example: Select the “name” and “class” columns from the “etable” table.

				
					SELECT name, class FROM etable;
				
			

Since, we did not insert any data’ therefore, it will show “Empty set”.

SELECT * asterisk

The following SQL statement selects all the columns from the “etable” table:

Example: Select the all columns from the table by using *.

				
					SELECT * FROM etable;
				
			

Since, we did not insert any data’ therefore, it will show “Empty set”.

If you find anything incorrect in the above-discussed topic and have further questions, please comment below.

Connect on:

Leave a Comment

Stay in the loop

codingstreets