0% found this document useful (0 votes)
17 views

Database System Lab-6

Uploaded by

Hafiz Mian 10
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Database System Lab-6

Uploaded by

Hafiz Mian 10
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

SQL Aliases

Database system
Aliases

 SQL aliases are used to give a table, or a column in a table, a temporary name.

 Aliases are often used to make column names more readable.

 An alias only exists for the duration of that query.

 An alias is created with the AS keyword.


 SELECT StudentID AS ID
FROM Student;
aliasing used on column & Table

 SELECT column_name AS alias_name


FROM table_name;
 SELECT column_name(s)
FROM table_name AS alias_name;
Concatenate Columns

 SELECT ID, Student_name + ', ' + PostalCode + ' ' + City + ', ' + Country AS Address
 FROM Student;
 SELECT o.OrderID, o.OrderDate, c.CustomerName
FROM Customers AS c, Orders AS o
WHERE c.CustomerName='Around the Horn' AND c.CustomerID=o.CustomerID;
SQL SELECT DISTINCT Statement

 SELECT DISTINCT Country FROM Customers;


Task

 Write a SQL query that retrieves the ID, Contact, and Student name Address ," using table aliases, and then
retrieve a list of distinct Cities from the Student table.
Answer

You might also like