Are you asking about table aliases? Table aliases are a way to make your query more readable and easier to type. For instance:
No aliases:
SELECT employee.firstname, employee.lastName, company.officeNumber, payroll.grosspay
FROM employee
JOIN company ON employee.employeeID = company.employeeID
JOIN payroll ON payroll.employeeID = employee.employeeID
ORDER BY employee.lastname, employee.firstname
Made simple with aliases....
SELECT emp.firstname, emp.lastName, comp.officeNumber, pay.grosspay
FROM employee emp
JOIN company comp ON emp.employeeID = comp.employeeID
JOIN payroll pay ON pay.employeeID = emp.employeeID
ORDER BY emp.lastname, emp.firstname
This is a simple example, but with larger queries (especially self-joins) you can really see the difference.
-- Just trying to help... LOL
Hmm... Can I say that alias is for extracting data to another column of different name or extracting data to another table with different name N column contents ???
The alias allows you to make a vritual change to a column or table including using the abberviation shown above to make coding simpler. I think it is most important when you need to make multiple joins to the same table (e.g in the example below joining to a table of staff names twice to return the names of both the owenr and a salesperson (tables aliases shown in bold)
e.g.
select
sq.name,
s2.name
from
maintable m
innerjoin staff s1 on
m ownerid = s1.name
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.