Data Query Language (Part 1)

Gautami ShettyGautami Shetty
2 min read

Overview of SQL statements:

Sql statements are classified into 5 types-

  1. Data Definition Language

  2. Data Manipulation Language

  3. Transaction Control Language

  4. Data Control Language

  5. Data Query Language


Data Query Language

Data Query Language is used to fetch the data from the database

It has 4 statements:-

  1. Select

    It is a process of fetching/retrieving the data from the table and display it.

  2. Projection

    It is a process of fetching/retrieving the data from the table by selecting only the columns

    In projection all the values present in a particular column are selected by default

  3. Selection

    It is a process of fetching/retrieving the data from the table by selecting both rows and columns

  4. Joins

    It is a process of retrieving/fetching the data from the multiple tables simultaneously.


Projection

  • It is a process of fetching/retrieving the data from the table by selecting only the columns

  • In projection all the values present in a particular column are selected by default

Syntax -

SELECT * / [DISTINCT] COL_NAME/ EXPRESSION [ALIAS]

FROM TABLE_NAME;

💡
ASTERISK (*) - It means to select all the columns from the table and SEMICOLON (;) - It means the end of the query

Order of execution -

  1. FROM CLAUSE

  2. SELECT CLAUSE

In this example I have considered a table EMP which has ENAME column in it. I used Projection statement to extract that particular column from EMP table from the database and display the result table.

Working of Projection statement

  1. FROM CLAUSE is executed first.

  2. In FROM CLAUSE we can pass table_name as an argument

  3. The job of FROM CLAUSE is to go to the database, search for the table and put that table under execution.

  4. After the execution of the FROM CLAUSE, SELECT CLAUSE will execute.

  5. In SELECT CLAUSE, we can pass three arguments

    1. *

    2. COL_NAME

    3. EXPRESSION

  6. The job of SELECT CLAUSE is to go to the table which is under execution and select the column which we mention.

  7. SELECT CLAUSE is responsible for the result table.

0
Subscribe to my newsletter

Read articles from Gautami Shetty directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Gautami Shetty
Gautami Shetty