Data Retrieval language(DRL)

Share via:

Data Retrieval language(DRL)

Data Retrieval Language (DRL) is a part of SQL used to retrieve (fetch) data from a database without modifying it.
Main Command: SELECT – used to get data from one or more tables.
Examples:

Purpose:
To view data
To filter required information
To sort and display data in a useful format Marks-friendly line (for exams):
Data Retrieval Language (DRL) is used to retrieve data from a database. The SELECT command is used in DRL.

 

Distinct
DISTINCT is used in the SELECT statement to remove duplicate values and display unique records from a column.
Syntax:

→ Displays each city only once, even if it appears many times in the table.
Use: To avoid repeated values & To get unique data
Exam answer (short): DISTINCT is used to retrieve unique values from a column by eliminating duplicate records.

 

Expression Definition:
An expression in SQL is a combination of columns, constants, operators, and functions that is used to calculate or derive a value.
Examples:

Use: To perform calculations, To compare values & To filter data
Exam-friendly line:
An expression in SQL is a formula used to compute or evaluate values using operators and operands.
Definition:An alias is a temporary name given to a column or a table to make the output easy to read. It does not change the original name.
Syntax:
SELECT column_name AS alias_name FROM table_name; (or AS is optional)
Examples:

Use:
To improve readability To shorten long names
Useful in expressions and joins
Exam-friendly line: Alias names are temporary names given to columns or tables using AS for easy identification.

 

Operators
Definition: Operators are symbols used to perform operations on data in SQL expressions and conditions.
Types of SQL Operators:
Arithmetic Operators
+ , − , * , / , %
Example: SELECT marks + 10 FROM students;
Comparison (Relational) Operators
= , != , > , < , >= , <=
Example: SELECT * FROM students WHERE marks >= 60;
Logical Operators AND , OR , NOT
Example: SELECT * FROM students WHERE marks > 60 AND city = ‘Mumbai’;
Special Operators
IN , BETWEEN , LIKE , IS NULL
Example: SELECT * FROM students WHERE city IN (‘Pune’,’Delhi’); There are three types of operaters

 

Arithmetic operators
Arithmetic operators are used in SQL to perform mathematical calculations on numeric data. Types of Arithmetic Operators
Operator Name Description Example
+ Addition Adds two values marks + 5
Subtraction Subtracts one value from another marks – 10
* Multiplication Multiplies values marks * 2
/ Division Divides one value by another salary marks / 2
% Modulus Returns remainder after division marks % 2
Examples with Explanation

To calculate totals, averages, discounts To modify numeric values in queries Used in SELECT, WHERE, and UPDATE
 *Arithmetic operators in SQL are used to perform mathematical calculations on numeric data. They include +, −, , /, and %. These operators are commonly used in expressions to calculate totals, differences, and other numeric results.

 

Relational (Comparison) Operators 
Relational operators are used in SQL to compare two values. They return TRUE or FALSE and are mainly used in the WHERE clause.
Operator Description Example
= Equal to marks = 60
!= or <>. Not equal to marks != 50
> Greater than marks > 60
< Less than. marks < 40
>= Greater than Or equal to. marks >= 75
<= Less than or equal to marks <= 35
Examples with Explanation

Uses

To filter records
To apply conditions
Used with WHERE, HAVING
> Relational operators are used to compare values in SQL. They include =, !=, >, <, >= and
<= and help in filtering records based on conditions.

 

Logical Operators
Logical operators are used to combine multiple conditions in a SQL query. They return TRUE or FALSE.
Types of Logical Operators

Uses
To apply multiple conditions To filter data accurately
Used mainly in WHERE and Having
> Logical operators in SQL are used to combine conditions. AND, OR, and NOT are the logical operators that help in decision making.

 

 

Author    : Lavanya Nandairi
LinkedIn : https://www.linkedin.com/in/lavanya-nandagiri-817194375/
Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates.
KTExperts is always active on social media platforms.
Facebook  : https://www.facebook.com/ktexperts
LinkedIn    : https://www.linkedin.com/company/ktexperts/
Twitter       : https://twitter.com/ktexpertsadmin
YouTube   :  https://www.youtube.com/c/ktexperts
Instagram  : https://www.instagram.com/knowledgesharingplatform
Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Add Comment