Ambiguous column name 'ProductID' in asp.net

Since the column ProductID is present in both tables, the WHERE clause find it Ambiguous. So,

Replace ProductID=@ProductID with o.ProductID=@ProductID

update o set o.Updatedproduct = p.ProductQuantity - o.Totalproduct 
from CustomerProducts o 
inner join Products p 
on o.ProductID = p.ProductID WHERE o.ProductID=@ProductID

Comments

  1. Elliot

    • 2019/1/26

    — that is the “Name” column. The SQL Machine is confused as to which “Name” out of the two tables you are referring to. It is ambiguous — not clear.

  2. Rory

    • 2018/7/18

    This means two columns have the same column name — that is the “Name” column. The SQL Machine is confused as to which “Name” out of the two tables you are referring to. It is ambiguous — not clear. To clarify this, add the alias of either or both TABLE1 or TABLE2 to the columns having the same name.

  3. Joel

    • 2017/4/9

    We face this error when we are selecting data from more than one tables by joining tables and at least one of the selected columns (it will 

  4. Caspian

    • 2018/9/26

    Ambiguous column name. select tbl_registration.*, tbl_ebp.name as ebp_name, tbl_Users.id as user_id, tbl_ebp.id as linked_ebp_id from tbl_registration left outer join tbl_ebp on tbl_ebp.id = tbl_registration.ebp_id left outer join tbl_users on tbl_registration.email = tbl_users.username where id = [PARAM]p_id.

  5. Jordan

    • 2021/7/1

    “Ambiguous column name” means that you are referencing an attribute or attributes that belong to more than one of the tables you are using in the query, and 

  6. Jamison

    • 2017/8/3

    Ambiguous column names When joining tables, we use aliases in the SELECT statement to indicate the source tables of the selected columns, with each column name prefixed with the table name alias. The following query joins the Players and PlayerStats tables to return total points by PlayerName and Country for all players from Australia.

  7. Aron

    • 2021/3/17

    Here is an example of Ambiguous column names: When joining tables, we use aliases in the SELECT statement to indicate the source tables of the selected 

  8. Lincoln

    • 2016/11/9

    The reason behind you getting this error is when you join two or more tables then it will comes up with a common recordset to the select while there are more than one column having the same name so the system is unable to understand which value you want to put there, that's why system generates ambiguity in column name error message.

  9. Brandon

    • 2019/9/22

    Ambiguous column name '%.*ls'. Severity level: 16. Description: This error message appears when SQL Server is not able to uniquely resolve the column name 

  10. Costa

    • 2018/7/16

    Msg 209, Level 16, State 1, Line 9 Ambiguous column name 'Created_Date'. Msg 209, Level 16, State 1, Line 17 Ambiguous column name 'Created_Date'. Msg 209, Level 16, State 1, Line 18 Ambiguous column name 'Created_Date'. Msg 209, Level 16, State 1, Line 19 Ambiguous column name 'Created_Date'.

  11. King

    • 2019/11/23

    You will get this error WHENEVER your SELECT, JOIN ON, WHERE, GROUP, HAVING do not fully qualify the column AND there are more than 1 columns with that name 

  12. Holden

    • 2019/2/8

    BigQuery: Column name is ambiguous even after applying alias 0 Airflow - Generating tasks dynamically from BigQuery, but tasks are run repeatedly before previous finishes

  13. Rocco

    • 2016/7/20

    SQL compilation error: ambiguous column name. Submitted by yoon on ‎12-04-2019 02:39 PM. Power BI services, connected to Snowflake, generates SQL that 

  14. Evan

    • 2016/2/11

    However, now the issue is "ambiguous column name,'area'. The query below returns correct data. However, it queries the entire table (80k rows).

  15. Harris

    • 2019/8/16

    Server: Msg 209, Level 16, State 1, Line 1 Ambiguous column name 'LastName'. It is a good practice to always prefix column names with the table name or table 

Comments are closed.

Recent Posts