Solved

Ambiguous column name

Posted on 2004-08-10
6
1,435 Views
Last Modified: 2008-01-09
I have a coloum called OBCUSD within a table and when ever i run a sum on this coloum i get a "Ambiguous column name" error appear.

A: what is this
B: how can i over come it? I tried to do a SELECT OBCUSD AS 'OTHER_NAME' But this did not work for the query that i want and then it want me to group By this field

willa
0
Comment
Question by:willa666
6 Comments
 
LVL 39

Expert Comment

by:appari
ID: 11760312

can you post the query you were trying to execute?
0
 
LVL 26

Accepted Solution

by:
Hilaire earned 125 total points
ID: 11760342
Most likely your query performs a select using JOINs on several tables
The "Ambiguous columnn name" error means that the column name can be found in several tables, so you have to use more qualified names, either using the table name as a prefix, or an alias if you use some

SELECT YOURTABLE.OBCUSD , .....
or

SELECT a.OBSCUSD, ......
FROM YOURTABLE a INNER JOIN ....
0
 

Expert Comment

by:candelaboy
ID: 11760393
please paste your sql query.
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 5

Expert Comment

by:amit1978
ID: 11760611
Hello willa,

This error occure if an query haveing coloumn of same name (weather ur useing thous column in query or not) in two different table and table name or alins is not prefix with that column.

what u have to specify the table name before the column name.

amit

0
 
LVL 1

Expert Comment

by:dacz
ID: 11760938
i think amit1978 is right.
0
 
LVL 1

Expert Comment

by:jasonwisdom
ID: 11763530
This happens when two returned fields have the same name.  For example,

SELECT a.id, a.name, b.id, b.name
FROM users a, addresses b
WHERE b.id=a.id

You'll still get two duplicate sets of columns, two each of "id" and "name".

Much better is to include AS clauses, for example this:

SELECT a.id AS userid, a.name AS username, b.id AS addressid, b.name AS addressname
FROM users a, addresses b
WHERE b.id=a.id

Using an AS identifier is called using an alias.

Moreso than specifying (tablename).(fieldname), you should re-alias your returned fields so your recordset, datareader, etc. knows what to grab when it's specifying a column by name.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question