Q
Problem solve Get help with specific problems with your technologies, process and projects.

Use column alias to query same field names

I'm doing a query that scans multiple tables based on certain conditions. My problem is that some of the field names are the same in the result set, and I am unable to reference the particular field I want. I have tried using the syntax "tablename.fieldname" but get an error. If I just put "fieldname" I get the last occurence of that name in the result set.

Alias at least one of the columns using the AS keyword.

select MyTable1.ID as ID1, MyTable2.ID as ID2 
  from MyTable1, MyTable2
  where MyTable.ID = MyTable2.ID

For More Information


This was last published in September 2002

Dig Deeper on Oracle and SQL

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close