tags:

views:

190

answers:

4

I have two tables with one identical column name, but different data. I want to join the tables, but access both columns (row["price"], row["other_price"]): How can I rename/alias one of them in the select statement? (I do not want to rename them in the DB)

+5  A: 

select table1.price, table2.price as other_price .....

MrTelly
+2  A: 

us the AS keyword

select a.Price as PriceOne, b.price as PriceTwo 
from tablea a, tableb b
Dead account
+5  A: 
select t1.Column as Price, t2.Column as Other_Price
from table1 as t1 INNER JOIN table2 as t2 
ON t1.Key = t2.Key

like this ?

Matt
A: 

if you are using sql server, use brackets or single quotes around alias name in a query you have in code.

Kunal S