MS SQL Server Concepts and Programming Question: Download MS SQL Server PDF
How To Define and Use Table Alias Names in MS SQL Server?
Answer:
When column names need to be prefixed with table names, you can define table alias name and use them to prefix column names. To define an alias for a table name, just enter the alias name right after the original table name in the FROM clause as shown in the following select statement:
SELECT l.id, l.url, r.comment FROM ggl_links l
INNER JOIN ggl_rates r ON l.id = r.id
GO
id url comment
101 www.globalguideline.com The best
102 www.globalguideline.com/html Well done
103 www.globalguideline.com/sql Thumbs up
SELECT l.id, l.url, r.comment FROM ggl_links l
INNER JOIN ggl_rates r ON l.id = r.id
GO
id url comment
101 www.globalguideline.com The best
102 www.globalguideline.com/html Well done
103 www.globalguideline.com/sql Thumbs up
Previous Question | Next Question |
How To Write a Query with an Inner Join in MS SQL Server? | How To Write a Query with a Left Outer Join in MS SQL Server? |