At 07:36 PM 2/20/2005, Dick Fey wrote:
I have never used alias.
Can you give me a short example?
Dick,
Here are a two short examples.
Example 01: (Using AS method)
Suppose, three columns (TransID,EmpID,TransDate) in TransMaster table need to be ALIASed in a view called ViewWithAliasCols.
-- Start SET ERROR MESSAGE 677 OFF DROP VIEW ViewWithAliasCols SET ERROR MESSAGE 677 ON CREATE VIEW `ViewWithAliasCols` AS SELECT + CustID,TransID AS TransxID,EmpID AS EmployeeID, + TransDate AS TransxDate,NetAmount,Freight,Tax, + InvoiceTotal FROM TransMaster COMMENT ON VIEW `ViewWithAliasCols` IS + 'Copy of TransMaster Table with Alias Names' RETURN -- End
Notice that:
. Column TransID is aliased as TransxID . Column EmpID is aliased as EmployeeID . Column TransDate is aliased as TransxDate
Example 02: (Using Pre-Defined Column Names method)
Suppose, three columns (TransID,EmpID,TransDate) in TransMaster table need to be ALIASed in a view called ViewWithAliasCols2.
-- Start SET ERROR MESSAGE 677 OFF DROP VIEW ViewWithAliasCols2 SET ERROR MESSAGE 677 ON CREATE VIEW `ViewWithAliasCols2` + (CustID,TransxID,EmployeeID,TransxDate,NetAmount, + Freight,Tax,InvoiceTotal) + AS SELECT + CustID,TransID,EmpID,TransDate,NetAmount, + Freight,Tax,InvoiceTotal + FROM TransMaster COMMENT ON VIEW `ViewWithAliasCols2` IS + 'Copy of TransMaster Table with Alias Names' RETURN -- End
Notice that:
. Column TransID is pre-defined as TransxID . Column EmpID is pre-defined as EmployeeID . Column TransDate is pre-defined as TransxDate
That's all there is to it!
Enjoy and make sure to have fun!
Very Best R:egards,
Razzak.
